As the king is the most important piece, it's vital that you know what to do with him. The more pieces there are on the board, the less safe the king becomes. It is especially dangerous for the king when the enemy queen is still on the board. When discussing the king's role in chess strategy, we are mostly interested in how to keep him safe from attack. Only in the endgame, when there are few pieces left on the board, is it safe for the king to emerge from his fortress and join in the attack, but we will look at the role of the king in endgames in a later tutorial.
One of the most important things to remember early in the game, is to castle your king to safety in the corner. You may be wondering why it is so much safer for the king in the corner than in the centre - after all, isn't he more likely to get trapped in a corner? Well, sometimes, but the big reason to get the king out of the centre of the board is because the centre is where most of the action occurs. The centre in chess is the high ground. Occupying it confers a strategic advantage, and both sides should be fighting to control it for themselves and deny it to the enemy. The central pawns need to move to let out the pieces and fight for control of the centre, and they are often exchanged off, leaving the central files open. The king is far too vulnerable to be left in the middle of this battle.
It's obvious that the king can't stay in the centre once the central pawns have moved out to fight for the centre. The safest position for the king is behind an undisturbed line of pawns. Once you have castled, you should keep the pawns in front of your king unmoved for as long as possible. Sometimes you need to move a pawn to avoid a back rank checkmate, and sometimes it can be tempting to move your pawns to attack an enemy piece, but remember pawns cannot go backwards and once you have weakened your king's fortress, it will remain weakened for the rest of the game. A loose pawn formation around the king is an invitation for your opponent to attack there.
Even if you don't move the pawns in front of your king, your opponent may be able to force them aside with an exchange, as in the following example:
Sometimes, one player will try to open up lines against the opponent's king by advancing pawns and attempting to exchange them for the defending pawns. This is known as a pawn storm, and can be a dangerous attacking technique. Usually, if your pawns have not yet moved, you can avoid exchanges by sidestepping pawn challenges and locking the pawn structure, as in the following example: