Because spears are easier and quicker to produce, easier to use without extensive training and are easily replaceable. Not to mention that spears provides troops with more tactical flexibility whether we are speaking about cavalry, or infantry.
Sword, long knive or cutlass (in fact in the Medieval times majority of infantry "swords" were rather a kind long knives with one cutting edge, like
this one) in battle was warriors weapon of last resort, when he expended all arrows, throwing spears, or his thrusting spear was broken. Or when close combat formation was broken and every warrior was fighting on his own. Each of these situations was not very desired in general.
Also, keep in mind that in the RoP time frame most units aren't professional warriors. And even a few of professional troops are issued with their weapons by state - the cheapest is weapon, the better. Babylonian army is a good example, though they were issued with basic swords.
Then there is a matter of training. Most of RoP troops are levies. These men have everyday diuties, jobs and families and not a lot of time for an extensive training - this is true especially with Greeks. Not every hoplite was really trained with sword, many of them doesn't even carried swords.
Spears are far easier for use, especially in larger groups of soldiers. It's easier to attack or defend yourself with large shield in one hand, and spear in another (and it's even easier to attack from horseback with spear, than with relatively short sword).
And the last is matter of tactics. Large group od men armed with long spears are very effective both in attack and in defense. They don't need to have a lot of training, it's enough if they know how to march in more or less tight formation and are disciplined enough to keep their place on the battlefield.
In short - spear, especially paired with a shield -is your everyday "noob friendly weapon". Good for conscripts, good for professionals, cheap, and even if it's lost or broken you can easily find another one.