Just like the Queen, the King can move straight in any direction or diagonally in any direction. The Queen has maximum range and can move to one side of the board to the other in one move provided her path isn't blocked.
But the King can only move one square at a time, he has minimum range. Because of this lack of mobility the King usually tends to spend much of the game tucked away in a corner where the enemy has difficulty reaching him.
In the endgame when many of the pieces have left the board, the King can take a more active role in the battle. Now it is safer for him in the open when he does not face the imminent threat of checkmate.