In this game, which I played on Gameknot against a player rated at the time in the lower 1600s (and with an all-time-high ranking of 1691), my opponent, playing Black, castled into danger on the kingside.
In the illustration, the critical moment has arrived. Black’s kingside pawn structure has been disrupted by an exchange of minor pieces, leaving an undefended Black pawn on g6. Now would not be a good time for Black to castle on the kingside, but that is exactly what Black did!
When it comes to castling in chess, we are usually taught to castle early, after developing some of the minor pieces.
The idea is that it can be dangerous to leave your king stuck in the middle of the back row where he may be exposed to an early attack. Generally speaking, it is more secure to get your king off to one side of the board, behind a barrier of pawns, and perhaps a knight, a rook and/or a bishop.
In the diagram both White and Black have castled early. White’s king is defended by three pawns, a knight and a rook. Black’s king is even more securely defended by three pawns, a rook, knight and bishop.
Quite often, however, other concerns cause one or both players to delay castling, or not to castle at all. In a situation where you have castled and your opponent has not, Jeremy Silman offers a “basic thesis” for you to follow, which is,