I know that on old timey battlefields (lets just say before the introduction of effective mass-deployed firearms) pole weapons of various types were pretty much king, due to economics, effectiveness and especially what they gained from fighting in formation.
I also know that many people (for example the Vikings) made very effective use of axes.
With all of this being said, I'm struggling to see what advantages a sword would have had, apart from it being easy to carry around on ones hip (sort of like a pistol, now that I think about it).
I've heard people say that swords would have been better one-on-one than spears and such because the spears lose the advantage they gain from fighting in a formation, but on the other hand, I've seen plenty of explanations and demonstrations of how effective spears and the like can be even in situations like that.
So swords didn't have the power of an axe, the reach of a spear, or the anti-armor capabilities of blunt weapons such as maces. So what did they have?
Thank you
Much of our knowledge surrounding the use of premodern weaponry is clouded by the limitations of our sources. I have mentioned in many of my previous answers that we have very few medieval sources from non-elite perspectives. While many of our elite sources spend a great deal of time discussing wars and battles, they rarely do so in the sort of technical detail that modern scholars and people with an amateur interest in warfare might wish for. In the absence of much direct evidence for how weaponry was used across hundreds of years and vastly different cultures, these subjects are furiously debated both in the scholarship and on internet forums. Often it seems that re-enactors and other amateur enthusiasts take far more of an interest in the subject of arms and armor than most scholars do. This isn't a bad thing at all- some quite interesting work has been done by enterprising types outside of the historical academy- but it does mean that sometimes these discussions move outside the realm of historical knowledge and into speculation driven by RPGs and other fiction.
Medieval European warriors (who I am much more familiar with than ancient sources) did not necessarily see weapons in such game-driven terms. Medieval soldiers saw little value in valuing one weapon over another. In fact, we see the exact opposite occur: medieval warriors (depending on their social status, culture, financial situation, etc.) trained and wielded multiple weapons, switching between them as the situation warranted. The late medieval man-at-arms or knight who participated in the Hundred Years War would have trained to use the lance, the sword, the poleaxe, and in unarmed wrestling techniques as well. His common counterpart, the archer, would be expected to not only be skilled with the bow, but also with the sword and other hand weapons as well (various kinds of short pole weapons are often mentioned). Contrary to what certain strains of popular received wisdom on the subject, the sword was not necessarily a weapon reserved for the elite. That might have been the case for Carolingian France or Anglo-Saxon England, but by the high to late medieval period, the price of a sword was relatively inexpensive, especially for the demographic of individuals who would be most interested in a career in arms. Sword and buckler play was a relatively common late medieval sport/recreation/form of training among the population at large. So the ownership of swords and use thereof was prevalent among both elite and non-elite demographics.
But why swords to begin with? This has been a somewhat abstract answer so far, but let's look at the actual nitty-gritty of combat and medieval warfare. For one, I think you're downplaying the advantage of being able to keep a weapon safely attached to your hip with relative ease. As soldiers of any period can attest to, hauling gear around is one of the most onerous parts of military service. Being able to have a spare weapon strapped to the hip frees up both hands, allowing a soldier to carry a different weapon in his hands, or possibly a shield as well. Weapons often broke, got dropped, or got stuck in bodies during hand to hand combat. It wasn't very practical to haul around an extra poleaxe or pike in case your weapon failed. A sword can not only be carried easily, but also drawn quickly in the heat of a fight.
There are also other advantages to a sword besides the convenience factor. In terms of pure physics, a sword may not generate quite as much force on the point of impact as an axe can, but that's not always the sole mark of a weapon's usefulness. Most medieval arming swords were double-edged, allowing the full length of both sides to be used effectively, and also could be used to stab with the point. Unlike a dane axe, poleaxe, or a pike, a one-handed sword can also be wielded with a shield, which was useful not only in hand to hand engagements but also to defend from missiles. A longer weapon's reach can be a great advantage, but reach isn't always the most critical thing on the battlefield. Many medieval battle accounts describe engagements where the combatants are tightly packed or congested in a small space, which would not be helped by a longer weapon. Indeed, men at arms who are ordered to fight on foot are sometimes mentioned to have shortened their lances in order to have handier weapons. In the close quarters fighting at the Battle of Fornovo in 1494, the French infantry were said to have been much more effective with their one-handed swords than the Italian troops, armed with longer weaponry. Swords aren't necessarily short weapons, either. Even discounting the existence of longer, two-handed blades, a one-handed arming sword will have greater reach than many examples of maces and picks in Western european museums. Long-handled maces seem to have been a favorite weapon of Abassid and Persian horsemen, but these apparently did not become popular in medieval western Europe.
I also want to complicate some of the notions you have suggested in your post. A full-strength mace strike to the head will certainly make an impact on an fully-armored opponent (even if it merely stuns him through his helmet), but heavily armored men were pretty damn hard to kill regardless of weaponry. There are accounts of medieval warriors being riddled with arrows, hit with axes, and charged with lances and emerging relatively unscathed. Unless an opponent is wounded or running away, they are unlikely to simply allow you to maneuver yourself so that you can effectively strike them through their armor. A number of techniques, such as half-swording, emerged in order for soldiers to use swords effectively against armored opponents. The majority of casualties in a medieval battle would not happen in direct combat, but during the rout, when the losing side was fleeing and unable to effectively defend themselves. The exact degree of effectiveness for any individual piece of weaponry weapon mattered much less than is sometimes imagined. A comparison may be drawn to modern debates about small arms: the most important factor of WWII was most likely not the relative merits of the Russian Mosin-Nagant rifle over the German K98.
PS: I would be amiss in answering this without tagging in some other excellent flairs with relevant expertise. /u/iphikrates and /u/alriclofgar have both written some excellent posts on the use of weaponry in their periods of interest (ancient Greece and Anglo-Saxon England, respectively).
EDIT: I completely forgot to add: it is not universally the case that a polearm is less expensive than a sword. That might have been the case when metal was more expensive, but late medieval armory inventories and receipts do not agree with this assertion. Quite often, lances and other polearms were either more expensive or on par with prices for basic swords for regular troops (as opposed to the much more expensive weapons ordered by wealthy aristocrats).