The move referred to here is called castling, and the rook and king don't actually "trade places" as was suggested in the question. Castling is a maneuver that increases protection for the king and allows for development of the rook. Let's look at castling as see what really happens. Imagine a Chess board with only the two rooks and the king in place on it. They're on their starting squares. To castle, the king is moved two squares toward the rook on the side on which the player wishes to castle. The rook on that side, the side toward which the king was moved, is now placed on the other or far side of the king. It's as if the rook "jumped over" the king to get to the other side and stand adjacent to the king. It works the same for either side, and the king is moved those two spaces toward the rook with which it is going to castle, and the rook "jumps" the king and ends up alongside it. Castling can be done to either side using this mechanism. But there are restrictions to castling. The first rule of castling is that neither the king or rook can have moved for castling to be legal. Also, all intervening pieces on the side to which a player wishes to castle must be out of the way; the space between the king and rook must be clear of all obstructions. Third, if the king is in check, castling is prohibited. It is not a legal move to castle to get out of check. Lastly, the king cannot across a square that is under attack. Certainly the king cannot move into check, but recall that the mechanism of castling begins with moving the king two squares toward the rook with which castling is desired. If that square that the king would move across is under attack by an opponent, castling is prohibited.
Chat with our AI personalities
There is a maneouvre in chess called castling. It can only be performed when neither the king nor the rook involved have been moved and when there are no pieces between them of either colour, and cannot be peformed while in check.
It allows you to move the king two places towards the involved rook; the rook is then placed on the opposite side of the king.
Not quite trading places. Under some circumstances, both the king and a rook (also called a castle) can BOTH move- at the same time. But they do not exchange places exactly. That move is called "castling".