And the range and penetration power of the early muskets wasn't better than arrows.
Accurate range was probably lower, but surely shot penetration was always far superior for a musket ball compared to any bow or crossbow.
Not really, and certainly not always… again depending on era. Prior to the modern era, firearms were custom-made one at a time just like swords and armor and the metallurgy and tolerances for a functional firearm were still more art than science. Likewise, each individual shot depended on the quality of the ball, amount of powder used, how well cleaned the barrel was, etc.
If your mold for making the balls was slightly too small for the barrel of your weapon or if you under loaded your powder you could have a ball that barely goes a dozen yards and with far less penetration than an arrow or crossbow bolt.
Heck, the very word “bullet-proof” came from smiths firing a pistol at point blank range into their armor’s breastplate. The dent it left was the “bullet proof” (i.e. proof it could stop a firearm).
Now, as time went on and the kinks were worked out the amount of armor needed to stop a bullet increased; which is why we see the pullback to just breastplates and helmets by the 1400-1500’s and eventually abandoned entirely until armor technology finally caught up in 20th century and our solders started wearing body armor again.
But no… depending on era, there is no guarantee that a firearm would have more penetration than, say, a crossbow. I mean, Benjamin Franklin made a serious case to the Continental Congress that Washington’s army be equipped and trained with bows and arrows because muskets still weren’t THAT much superior in penetration or range (particularly once everyone stopped wearing armor) and bows had massively better rate of fire.
It was rejected, but the fact thaf it wasn’t just laughed out of Congress and Franklin’s reputation ruined by the proposal says a lot about where the technology was at that point.
Even more amazing is that it wasn’t until World War I that the US Army stopped considering the Bayonet (i.e. a spear) to be the primary weapon of the infantry (i.e. tactics were to use gunfire to soften up the enemy before a bayonet charge). The doctrine was starting to change because of the Civil War and the improvements in weapon technology (particularly the revolver, the repeating rifle and the Gatling gun) were requiring it… but WW1 was the first time all those advances came together into a conflict that highlighted the supremacy of firearms over everything else.
In terms of the Medieval period, early firearms starting showing up in siege warfare by the 1300’s, but wouldn’t be anything useful for adventurers to be carrying around until well into the Renaissance with the matchlock (i.e. stick a burning string into the fire hole to ignite the powder… hope it doesn’t get wet, and good luck sneaking around while carrying a burning rope) emerging around 1475 and wheelocks as a very expensive alternative to the matchlock in the early 1500’s and true flintlocks (what we mostly think of as primitive firearms) didn’t become prominent until the late 1600’s (though earlier less reliable versions like the snaplock had been around since the late 1500’s).
Short version… if you’re playing in the late Medieval period, firearms are either a curiosity or something used in sieges by extremely wealthy nobles. Until you’re out of the Renaissance and well into the Early Modern period around the 1700’s firearms are going to be fairly cumbersome and difficult to use on your typical dungeon delve (and basically useless as soon as any amount of rain or water is involved).
Even with D&D’s typical schizotech firearms useful for adventurers would be a stretch and something akin to how they’re commonly presented (i.e. need just 6 seconds/1 turn to reload) should basically be a magic item (one of the more common things I’ve seen in various settings is to make gunpowder explicitly an alchemical/magic consumable).