Spearmen are very useful to have around when enemy cavalry are attacking. simply stand behind them and let them do all the work. Spearmen are not very effective melee troops, but are still able to quickly halt the advance/retreat of an enemy by pointing their spears in the enemies direction. This can be useful when trying to escape, to heal your troops, or prevent the enemy from fleeing, or even attacking your Archers.
In defensive stance spearmen can immobilize enemy troops in their front. Spearmen are especially effective against Cavalry.