Most melee weapons are way simpler and cheaper to make than firearms, especially when you don't have access to mass production techniques. A good sword would probably run you the equivalent of 100-200 dollars, where as a good pistol or rifle (not just a crappy flint or wheel lock, or a blunderbuss) would be more in the range of 500-1000. A firearm requires more technical skill to make, and also runs out of ammunition. Bullets, unless you have a musket, are pretty expensive. It's the old Economy vs Functionality argument.