There are two enormous fallacies at work here:
The first being, of course, that guns in the hands of even the most unwashed peasant-- much less the leveled D&D warrior!-- are magical death talismans that cannot be withstood or countered. Sometimes they punch lethally through the armors designed specifically to counter them, sometimes they have access to a much deadlier critical hit system than other weapons, sometimes they just have the absolute ability to oneshot kill absolutely anything on a Save or Die basis.
This is, in my experience, almost always the work of game designers with very little exposure to armed violence from either a professional or-- more importantly-- an academic perspective.
Second... and more pernicious... we are looking at the damage of firearms versus swords in terms of damage dice compared to the number and size of Hit Dice of human opposition. I don't feel like I should ever have to explain this to functional adults, but here we are: the measurement of weapon damage in die sizes compared to humanoid hit dice is also, entirely in itself, complete rubbish. Absolute nonsense.
If you're an untrained, unwashed peasant and you take a "solid blow" from a sword-- any kind of sword-- you die. If you take a vital shot from a firearm, literally a shot to the vitals, you die. If you take a solid blow from an arrow, a bolt, or a slung stone... regardless of the difference of those weapons' relative damage dice, you die. If the shot doesn't kill you, then whether you can keep fighting or you're forced out of the battle, you're going to spend months making whatever partial recovery is possible for you.
Thing is, though, it's the same for trained warriors. Their training and their equipment allow them to prevent some of those solid blows from disabling or killing them, but if a "lucky punk" gets a lucky shot with a flea-market switchblade, in the first round of combat-- something D&D rules don't model-- then the trained warrior, with more than one Hit Die that is more than a d4 in size, will die. If they take their helmet off and a small child throws a chunk of masonry at their exposed head, they die. Needless to say, if small arms fire breaches their armor... they stand a good chance of dying.
But not 100%, either. In the modern world, the rule is that if your heart is still beating when you're rolled into the trauma surgery, you're going to live. If a bullet doesn't hit a vital organ or a major artery, the human body can withstand a whole bunch of them; the reason being shot multiple times is more likely to be fatal is that you're more likely to get hit in something you need.
The only real difference, realistically speaking, between firearms and melee weapons is that the larger a firearm is, the more likely it is to kill you, while with a melee weapon, the larger it is, the less likely it is to crush or sever something important and kill you.
And the problem with this argument is, for the most part, we're trying to shove one truckload of nonsense into another and then demand it make sense.
Firearms, especially early firearms, are generally appropriately (if not realistically) depicted in terms of their rate-of-fire and reloading speed. Simply assign them whatever damage value you feel is right, in terms of how desirable you want them to be as player choices, and you're good to go. It's all nonsense anyway. There is nothing about the interaction between weapon damage and human injury in D&D that is even remotely realistic, so just go with whatever feels most natural in the combat rules you're already using. I think 5e's firearms rules are pretty okay, in comparison.
Personally, I like to go with d20 Modern's 2d4/2d6/2d8/2d10 classifications, with their default 20/x2 crit ranges... and if I can be bothered, I might do something about their ridiculous (short) rifle range increments and their even more ridiculous (long) pistol range increments.