CapnZapp
Legend
I guess this is what the random magic tables lead to.You could go the "old school" route, and make them more popular by virtue of magic. If nearly every magical sword you find in a longsword rather than a rapier or polearm, then some people might end up using them even if they aren't ideal for their build.
It does raise the question of why so many people would bother to enchant longswords, if they weren't very popular in the first place, but that tradition might theoretically date back to a time before rapiers were invented.
But it is also a slightly unfun solution.
It effectively asks players to abstain from picking the best choice just because that choice MIGHT not end up the best choice after all.
I believe it is better to be upfront already from the start, and make sure the weapons you WANT the players to choose also are the best or among the best choices.
What I mean is: the simplest and most constructive way to look at 5E is to assume its designers WANT players to choose the rapier (unless they go two-handed).
If you want something else, you can then change the core reason as to why that is. Such as saying "Dex weapon deal Str based damage" for instance. It changes the foundation. It actually removes (rather than obscures) the tension, by aligning what the DM wants with what the game offers.