I hope this isn't too general, but I am talking about any warfare before the invention of firearms. In a one vs one duel between sword and pole arm, it seems like the pole arm has significant advantages; a pole arm can reach the sword wielder, while the sword wielder. Sure if the sword wielder gets close he can do a lot of damage, but getting close is extremely risky and tricky. A few advantages of the sword that I could think of is being able to use a shield and being more mobile, but do these advantages really outweigh the advantages of the pole arm? I believe sword users are also much more vulnerable to cavalry than pole arms.
Pole arms vary greatly in length and purpose. Everything from a Zulu iklwa, a short 1 to 2 meter personal thrusting weapon...
...to the 7 meter pike favored by everyone from Philip of Macedonia to Charles the XII of Sweden.
Swords also vary greatly from the Roman gladius, a short thrusting weapon meant to be used in a tight formation...
...to the massive Zweihänder, the German two-handed sword up to 2 meters long.
The iklwa, a pole arm, has more in common with the gladius, a sword, than it does with the pike. Similarly a Zweihänder, a sword, being so long had some of the characteristics of a pole arm.
Then there's "any warfare before the invention of firearms" which is everything from ancient Greeks to Shaka Zulu (firearms did not have an important role in the wars between South African natives during the Zulu Expansion).
It's hard to make sense out of such broad categories and 2000 years of warfare, but I'll give it a shot.
Why were swords used in battle?
Very broadly speaking because in well trained hands they're good at close, individual combat and can be worn conveniently hung on a belt or slung over the shoulder. Polearms must be carried in the hands making them inconvenient. Swords are the medieval equivalent of a sidearm like a pistol.
However, battles are not won by close, individual combat. They're won by groups. This is why the sword was a secondary weapon. The primary melee weapon was the polearm.
A short spear has many of the advantages you list, and this video goes through them in some detail, but that's for a short spear one-on-one. It would be very different if he were wielding a pike.
Pole arms got longer and longer to make them more effective as a group, and less one-on-one. Everything from the Macedonian phalanx to the medieval pike wall exploits a tight formation of men bristling with pole arms. Attacking this formation means fighting not one-on-one, but attacking the group as a whole. Because the work of the individual soldier is fairly simple, stay in formation and hold your pole arm, they don't need to be particularly well trained or physically fit. They were particularly effective against cavalry, so long as the cavalry attacked from the front.
Where swords remained particularly effective is as a cavalry weapon, particularly the sabre. Light and one-handed, you could slash at your enemies from above while still controlling your horse.
The Romans developed tactics that involved both swords and spears.
The spears ("pilum") were used first, and were throwing spears (not "polearms").
After the "shock and awe" administered by the throwing spears, Roman soldiers would close in with short, thrusting swords to finish the job. These tactics were similar to those used by men armed with (one shot) muskets, and bayonets, centuries later.
Such tactics required strong, well-drilled formations such as legions. It wasn't until the late Middle Ages that non-Romans could produce (and utilize) such formations and tactics.
Roman soldiers could also use their pilum as "polearms" against cavalry if necessary. That is to say that they were a lot more flexible than other infantry until those of a much later time.
Swords are Flexible
Polearms generally work well when you can keep a tight formation. The first several lines are all able to engage the enemy, making it difficult for enemies to close within striking distance. But if the enemy comes at you from the side, its very hard to turn your formation to face them.
On the other hand, a sword is a light weapon that does not extend far beyond your body. It is easy to change position - or move in an unexpected direction as a unit.
As an example - the Battle of Pydna (168BC) was a battle between the Roman Legions (armed with the gladius short sword) and the Greek Phalanx (armed with long spears). It initially went well for the Greeks, and the Romans were forced retreat to nearby foothills. However, as the Phalanx advanced over the rough terrain, their lines became disorderly. The more maneuverable Romans were able to quickly concentrate their forces at the places where the Greeks were weakest.
The result is that the Romans defeated a larger force, even after an initial setback.
Swords Pair with Shields
A large polearm generally precludes the use of a shield - you need both hands to wield a halberd or a dagger-ax. This leaves you more exposed to missile fire, such as from archers. A swordsmen is often (though not always) equipped with a shield.
Polearms are Heavy
I'm not sure that a polearm beats a sword one-on-one, as the OP suggests. In a dual the swordsman is in definite danger while at range - the polearm can strike while the sword cannot. But if the initial strike misses, or is blocked by a shield, then the heavy polearm may not be able to "reset" for a second strike before swordsman closes the distance. It would depend a lot on the fighters, their weapons, and, I suspect, luck.
The problem with a pole arm is that you can only kill one guy with it. If the unit with the spears outnumbers the enemy, fine, but if the enemy outnumbers you, then things will go bad.
For this reason elite units always fought with sword and shield because you may need to kill many people. With a spear you can stick one of them, but if you are facing five or six enemies, you need a sword.
Another issue with a spear is that it can take a long time to kill somebody because the wound is relatively minor. You could stick somebody with a spear and he might just keep going like the energizer bunny. With a sword you can cause massive wounds that put the enemy into shock and disables them almost immediately.