Castling moves the king behind other pieces in a defensive maneuver, but this is only available under certain conditions.
When castling, the participating rook moves as far towards the king as it can, and then the king jumps over the participating rook, landing right next to it.
To castle, use the Castle menu.