Matt Easton of Schola Gladiatoria (fencing club, Youtube channel, and historical research forum) is fond of saying "context!". In fact, he is so fond of saying "context!", that he says it even when it's not contextually appropriate.
Yes, in general, the best weapon for any given situation will depend "on context". In the context of a historical, pre-modern combat situation, you will not be able to say that there is one weapon which, in all cases, regardless of opposing weapons, armor, number of opponents, time of day, thing you had for lunch etc, will be superior to all other weapons.
That said, in most contexts, polearms are better than swords. This has been born out both by testing (HEMA practitioners and experimental archeologists), as well as by examinations of the historical and archeological record. Pole weapons were more popular than swords, because they were more effective than swords, in a wider variety of contexts.
Throughout much of history, swords were treated either as status symbols ("wall hangers"?) or as sidearms - as a secondary or even tertiary backup weapon on the battlefield, or as a day-to-day civilian defense weapon, similar to the "handgun in the glove compartment" thing we might see today (for weapons that could double as tools, knives, daggers, and hatchets were preferred). However, if you were a pre-modern person, you knew there was a fight coming, and you had your choice of weapons, then polearms would probably be the one you'd want.