Castling is a special move that you are allowed to play, though only just once, during a game. It is usually a good idea to castle if you can, as it gives you an easy way to move your king to a much safer position. Don't forget that your king is your most valuable piece on the board and the safer the king, the better!
Castling is different from all other chess moves as it is the only move in which you are allowed to move two pieces during one turn.
What you are allowed to do is to move your king either two squares towards the left, or two squares towards the right, and then move your rook, the one in the corner nearest to the king, around to the square on the other side of the king.
This is normally a very good thing to do, especially if you have not yet moved any of the three pawns on that side of the board, as they provide very good protection to the king. Also, the rook is now able to protect the king much better as it is no longer tucked away in the corner.
However, there are a number of conditions that you need to learn as you can only castle when all these conditions are met. These conditions are as follows:
There must not be any other pieces between the king and the rook on the side you are castling.
The king must not have been moved earlier in the game
Likewise, the rook must not have been moved earlier in the game, and, of course, the rook must be one of your original two rooks, not a new rook from a pawn promotion.
The king must not be in check, and neither the square that the king crosses over, nor the finish square for the king, can be under attack by the enemy.
Those are the conditions and you must make sure that all the conditions are satisfied before you can castle.When you start a new game of chess, it is usually a good idea to keep these conditions in mind so that you can castle once the opportunity arises. So, it is usually best not to move your king very early in the game because once the king has moved just once, you can never castle afterwards. This is true even if you move the king away and then move the king back to the start square again - once you have moved your king, you cannot then castle.
When you are castling, you must always move the king first, after which you move the rook. You are not allowed to move the rook first. This is because the king normally moves only one square at a time, so if you move your king two squares, then your opponent knows for certain that your are castling and allows you to move the rook. However, if you moved the rook first, then your opponent might think that the move was finished and might play the next move before you have had a chance to move your king. To avoid this happening, you must always move the king first while castling.