Why is castling disallowed when the king is in check or when the square the rook will be placed on is under attack?
What is the rationale behind this ruling?
Why is castling disallowed when the king is in check or when the square the rook will be placed on is under attack?
What is the rationale behind this ruling?
One rationale that I can think of for not allowing the king to move through check parallels that behind the possibility of capturing en passant after a pawn makes a two-square advance.
The typical pawn move is just a single square forward, and the possibility of advancing two squares on a pawn's first move was a relatively late addition to the game in historical terms. Since the "nature" of a pawn had long been to make a single square advance, when that new sort of pawn move came into being, the en passant capture was a natural counterpart: the pawn doesn't "jump" two squares ahead, but rather "marches" through the intermediate square, and an opposing pawn is thus allowed to capture en passant on the following move if it is in position to have captured the advancing pawn at the intermediate square.
With that explanation in mind, let's consider your rule. Like pawns, a king's typical, natural movement is only a single square in distance. And like the pawn's two-square advance, castling is a relatively new addition to the rules of chess that is intended to speed the game up. So just as the en passant capture reinforces the pawn's nature as a one-square mover, the rule prohibiting a king to castle through a checked square reinforces the king's nature as a one-square mover. He is thought of not as gliding over the checked square, but rather trudging through it. And just as an opponent's pawn has a chance to capture en passant, an opponent's piece guarding the intermediate castling square would be given the right to capture the king. Since that's not a legal part of chess, castling through check in the first place isn't either.
As for why castling is disallowed just because of the king being in check, I'm not so sure, but I'll speculate. If, in the analogy between chess and war, we think of a check to the king as a wounding attack, less severe than the lethal checkmate but damaging nonetheless, then it's reasonable to insist that the hobbled king can't make a swift, immediate escape via castling. But maybe that's just how I think of it.
The way I always understood castling is that it allows the player to move his king to safety. But this privilege does not come for free - it comes at the cost of a tempo. If a player was allowed to castle out of check, or over a checked square, then it allows him to postpone this powerful move until the very latest, effectively removing the penalty from the privilege.
For me, this rule has nothing to do with how the king (or any other pieces) move. It has to do with achieving a balance between attacking play and defensive play. Just like how a goal keeper in football can handle the ball in his penalty area (but not if it was back-passed to him by one of his own players), so the rule of castling is there to ensure that you get a defensive edge, but not for free. You have to work it into your strategy.
I just posted an answer to this question How did castling originate? and I think it offers a missing part of the answer to this questions as well: What the rationale is, behind not being able to castle out of check.
Historically castling was probably two moves (the rook move and the king's leap), that were merged into a double move, because they basically always followed directly one after the other. Just like the double move of the pawns.
And just like you cannot escape capture from an enemy pawn, by just moving past it, you cannot escape check by just castling: In both cases the "double move" is dissected into the two original moves - the pawn can be taken en passant and the king could still be taken after the rook move, making castling illegal.
In both cases the rationale is speeding up the game, without changing what was possible before.
Because that would be cheating. Well, to be fair, the reason is to make it reasonable that when all of the squares surrounding a king and the square it stands on are attacked by the opponent, the defender cannot simply warp away and out of trouble, while simultaneously delivering a new defender in the fray. The move would simply be too powerful.
However, you are allowed to do this:
[FEN "1r6/p2nkp1p/2B1pb1B/2p5/6r1/2P5/PP3P1P/R3K2R w KQ - 0 21"]
[Event "Todd Southam Memorial"]
[Site "Toronto"]
[Date "2004.06.13"]
[White "Krupnov, Maxim E"]
[Black "Smith, Hazel"]
[Result "1-0"]
[WhiteElo "2361"]
[BlackElo "2051"]
[SetUp "1"]
[EventType "schev (rapid)"]
1. Be3 Rxb2 2. Bxd7 Kxd7 3. O-O-O+ Kc6 4. Kxb2 {and White won in 42 moves} 1-0