Spear is a tool of survival, a weapon of war.
It is one of the oldest weapons and tools in use by human kind. Even other apes like chimpanzees and orangutans have been observed making and using spears for purposes of killing insects or fetching things. Being one of the oldest and most basic weapons, it is a quite effective melee weapon too.
The Sword is a symbol of courage and hounour … and of destruction and bloodshed.
It is not as old as the spear but its use was quite widespread across various cultures too. Most cultures have had an elite warrior class and a sword based martial art when they were at a certain era of cultural achievement.
It has been a long argument, which is superior? The spear or the sword?
This argument might be as long as the history of swords as well.
Let us consider how they might have come into existence…
Humans have an urge to live and survive. Along with this urge, they have another urge to save other people, resources or animals important to them. This urge bothered Hunter-gatherers too. The need to cut things like plants, pelts, flesh etc lead to knives. Knives are a great tool but they are not too much effective in keeping threats away. The very idea that might have lead to spears can be traced from the desire to keep threats or opponents at a distance, by attaching this knife to a longer stick. Easy to stab things at a distance.
Earlier they had to walk upto the target to stab them, with spears, they could do it at a talking distance.
The spear has accompanied mankind all the way to creation and maintainance of civilisation.
The sword, however could only have been possible much later when the particular civilisation in discussion had the technology to work with metal.
Metal, however, was expensive as it had costs of harvesting, extracting, refining, smelting, and forging.
A sword needs more metal than a spear. Naturally, it is much more economic to arm an army with spears than with swords.
The earliest swords had just been larger knives
What was the need of swords when we had spears?
Because, some swords could cut off some spears, or perhaps because swords are easy to wear and carry around than spears, they are smaller and lighter. Easy to get through a door etc.
Swords are fundamentally different from spears as they can do slashing attacks, they can do what spears cannot, chop off limbs or spears.
Yet, the spear has a longer reach and can be easily targetted to hit vital points. An argument against it is that the spear betrays its wielder when it is the most needed: when the opponent has come past the range where the spear can be employed. However, it is a good weapon to keep people at a distance, or end their efforts before they close the distance.
The popular response to this question is “it depends”. Indeed, it does depend on various circumstances and the context, however. There are more scenarios in recorded history where the spear has triumphed.
Spears have a mechanical advantage over swords. A swordsman has to get really lucky to be able to do damage to the weapon such that it is rendered ineffective. Furthermore, in a comparitively easier scenario, a swordsman has to get lucky not once, but twice to be able to render the spear ineffective, to close the distance AND deliver the killing bow. A spearman has an advantage in this aspect as they only have to do the latter, their weapon can do the former quite easily.