Interesting thought. Did you know that when new fangled steam powered ironsided ships were being built there was a thought that old methods of ship battles wouldn't work, and that they would have to resort to ramming each other like the Greek and Romans did? Turns out ironsided ships were too slow and not maneuverable enough to ram and somebody just figured out how to put bigger guns on them.
Yes. I knew that. But so far, we’re still mostly discussing wooden sailing ships, not Ironsides ones.
That said, there’s plenty of spells in D&D that would make battle on an even an ironsided ship more difficult than in our world. The aforementioned Warp wood is one. Heat metal is another.
Shrink Item is probably a must-have for an arcane saboteur.
The way around attacking easily from a distance is to figure out how hurt your enemy from farther away than he can hurt you. This is why we have aircraft carriers now, along with intercontinental ballistic missiles. The Romans didn't have effective ways of sinking a ship from a distance, sure they should shoot it full of arrows, or try to set it on fire, but the best way to do it was ramming. Fast forward 1700 years and we have cannons that can blow holes in ship to sink them, or set them on fire, or kill the crew, but you had to be able to see the ship visually. Fast forward 300 more years and now you don't need to see an enemy ship personally, your AWACs support aircraft has it on RADAR and is feeding your control system the location, a missile is launched and the enemy doesn't even see it before their ship is sinking.
And some magic spells- including the aforementioned Fireball- have fairly long ranges. Not as long as cannon, but long enough. And with accuracy being less of an issue.
How many cannon shots does it take on average to sink a warship?
All a caster need do is get a single Fireball to explode within its AoE of the gunpowder. How many times does a caster mistarget a Fireball?
Now imagine the discussion about manning a ship that essentially will be a bomb if it gets too close.
“Don’t get close, then.”
If there’s an elementalist, Druid or weather wizard on board, you may not have as much to say about the range as you might like.
You can apply the same logic to D&D games. Most modern ships don't have support AWACs to help them if something happens. Pirates certainly don't, even if pirates managed to get themselves a moderately sized ship they could mount proper artillery/naval guns too (where do they even get those?) they don't have the support system a modern military has available. In the same vein I'd suggest a D&D setting probably doesn't have enough wizards for every ship, even if I like the idea of flying blink dogs being your ship's aerial support just so we can have literal dog fights.
You don’t need a 6th level caster for every ship. You don’t need AWACS.
An edict creating a cadre of well-compensated magical craftsmen under the seal of the crown could pump out a fair number of low powered wands and other dangerous magical items. And the UMD ability or ability to utter a command is going to be exponentially more common than actual casters.
And a smart ruler intent on ruling the seas would do exactly that.
All that said, don't even bother with wizards. What if the pirate ship is captained by a beholder? That thing just disintegrates holes the hull.
They’re not exactly sociable enough to want to command a crew. I mean, it could happen- I have a beholder who runs a Thieves’/Assassins guild- but that would be what...one ship out of tens of thousands? Hundreds of thousands?
I guess my point is don't over think D&D and ship combat too much. You'll end up in a weird place that doesn't necessarily make sense the way you want it to. Just roll with wizards working like particularly effective artillery and it works out in the end. This is especially true since the game revolves around the PCs being in the spot light, not the ship wizard of The Albatross (who is probably stat'd out as an NPC wizard/apprentice not a PC).
It’s too late for me. I’ve been considering D&D magic and how it would reshape societies and warfare for decades. I don’t often
change the worlds from the D&D defaults in that sense, but it’s always part of my thought process.
...just in case one of MY casters wants to be nasty.