It is quite a sophisticated set-up, really. You'd think in principle that the courts would decide when the presidency isn't following the law, but the actual power to punish the president lives in the legislature and it makes much more sense when examined in terms of what incentives exist.