The Spearman is a more advanced early unit than the Warrior, and very effective against cavalry. It is also more effective than the Warrior against ranged units and when attacking cities. However, the Spearman is at a disadvantage against the other frontline unit group, represented by the Warrior, so do not become overly dependent on it! A mixed force of Warriors and Spearmen should be your bet if you want early game domination.
At some point in the prehistory of civilization, some Neolithic warrior decided his club would be more efficient if he sharpened the end of it. And, hence, the spear. But the point kept getting dull from all the stabbing of animals and people. Soon enough people were hardening the points by charring them over fire (another recent discovery); the next innovation was attaching napped stone heads to the stick. And eventually, metal spearheads. Spears are fairly simple to master; and so were popular among the early militia that were the staple for most ancient armies. Spears can be produced fairly quickly and cheaply. And they worked well against those horse-riding barbarians. Over the centuries the spear went through endless evolutions, culminating with the bayonet, which a soldier can stick on the end of his rifle to make a spear for eviscerating the enemy once again.