Creating realistic shipboard combat can be a challenge for any GM. Every D&D combat has its own unique features, whether it be terrain, monsters, or magical elements, but getting players to feel like they are fighting and moving on a ship when they are rolling dice and crunching chips around the table in your gaming room is a real challenge. I use a combination of elements to some effect, but be warned. There's no magic charm here; these are all cheap tricks. You must have your players' interest before you can transport them anywhere.
Background sounds is one of the tricks that I use and Tabletop Audio is my go to site for it. They have tons of great stuff there and I'm sure that you can find something useful for your game no matter what genre it is. I also like to use music. Below is one of my favorites from YouTube, but you can find many others there, and many other places as well. In my experience with using sound in any form, a little goes a long way when it comes to using background audio to enhance your gaming. Set your volume so low that your players must work to hear it clearly. You want them to "absorb" the sound more than "hear" it.
In addition to background sounds, I also employ scents. I started with my own experimentations and I don't recommend that because if you are like me then you will end up with a lot of stinky messes that don't really smell like anything distinctive. What I do recommend is Adventure Scents. They have what I was looking for without all of the mess and wasted time. What I said about background sounds goes doubly for smells. It is much better to use too little and have no one smell anything, than it is to have someone tell your wife after gaming, "I think there might be a fish or something rotting under your couch." Trust me. For a pirate battle you really don't need anything expensive, a couple of pull string fireworks set off right before gamers arrive will put that gunpowder smell into the air without a lot of cost or mess.
The final trick that I use is forcing the players to interact with whatever the environment is according to their characters' backgrounds and skills. In D&D 5e, this is when the characters' traits, ideals, bonds, and flaws will come into play. A ship is a place where strength, hard work, determination, and dexterity are some of the most respected attributes. Sailors expect people to be able to pull their own weight. Physically weak characters are advised NOT to interact with the crew as they are likely to just be in the way wherever they go. A strong character that pitches in to help out, but doesn't seek glory will be well-liked by the crew. Physically weak characters and those secretive types that keep to themselves will be less well-received.
Finally, as an aid to making players feel more like their characters are involved in a ship combat, I present for your use 20 Critical Hits or Fumbles for Characters Fighting in a Ship to Ship Battle. I don't provide the damage numbers in this table. I leave the damage to you. Whatever it is, it shouldn't kill them outright. Scars are cool though. The whole idea around this table is to provide your players with a sense of the surprise and unpredictability of ship to ship combat during the age of sail.
Strain on the ship from previous damage causes a part of the main top spar to give way. It swings down carrying with it a section of burning rope and an ironbound pulley block, which strikes character squarely in the chest doing damage and will knock him/her overboard unless the player makes a dexterity save.
The mizzen topmast stay sail has torn loose from an enemy hit. It falls to the deck covering character and everyone else within 10 feet. The mizzen topmast stay cable (cable is a strand of nine ropes, tarred and whip-wrapped together; it's heavy) lands atop character with a dull thud doing damage and driving him/her to the deck.
The main top gallant stay cable has been damaged in an explosive attack. It falls, burning, to the deck and lands on top of character who is slammed to the deck and takes damage plus must make a dexterity save or take fire damage as well.
A stray piece of shrapnel from the battle causes a mounted oil lamp to explode all over character for damage. Character should make a dexterity save to avoid burn scars.
An explosively destructive hit to your ship's hull causes the air to momentarily be filled with jagged pieces of burning oak. Character stood between the party and the explosion taking damage; you should see what his/her back looks like.
A three foot length of steel chain, probably from one of the enemy's previous shots, jars loose from the mizzen mast and falls to the deck, striking character in the head for damage with a sickening crunch. Character must make a strength save or be carried to the deck by the chain.
The cross-yard jack and the two iron-bound pulleys that haul it up come down in a snap and sweep across the deck towards the sea. Character catches the brunt of the force taking damage and makes a dexterity save to avoid being carried overboard.
A solid hit shakes the entire ship and a former crewmate, killed earlier and trapped in the rigging above you, now falls on top of character for damage.
One of the unsecured halliards for controlling the main sail whips across character's face for damage. Character can also make a dexterity save to avoid a permanent scar across his/her face.
One of the gun tackles, weakened by a previous attack, gives way when the cannon fires. The ship's gun careens across the deck and smashes into character, who had better succeed on a dexterity saving throw or he/she will be getting a new peg leg.
A burning section of the mizzen topsail finally falls away from the charred mizzen mast spar towards the deck. The burning, pitch-covered mess lands on a character for damage. He/she will also have to make a save vs. dexterity to avoid burn scars.
One of the main top sail lift shrouds is whipping around in the wind and manages to strike character in the arm for damage. Character must make a deterity roll to avoid falling/being flung from the ship.
An overbalancing strike high in the rigging causes the ship to suddenly pitch 40 degrees to port. Character takes damage from debris on the ship crashing into him/her. Everyone must make a dexterity roll to avoid falling/being flung from the ship.
An effective use of chain-shot has torn away much of the ship's high rigging and thrown it into the sea. Both of the main top royal reef tackles swing wild, one-two, and both hit character for damage nearly knocking him/her into the waves.
A fire below decks has ignited an explosion from a small cask of gunpowder. Character takes the brunt of the damage. He/she must succeed at a constitution roll or be stunned for 1d10 rounds.
Shrapnel of burning wood and steel makes the deck a burning hell of damage and pain. Character shields the party from taking any damage, but takes damage and must must succeed at a constitution roll or be stunned for 1d10 rounds.
Damage to the ship causes one of the main yard tackles (used for lifting heavy burdens) to break free from the rigging above and swing down towards the deck. The pendulous iron-bound double-block and tackle catches character right in the head for damage. He/she must succeed on a constitution roll or his/her face is never going to look right again.
An armed attacker swinging toward your ship's rigging in true swashbuckler fashion is killed part way across. His armed dead body falls on top of character for damage. He/she must make a dexterity save or be forced to tell the tale of how you lost your eye to a dead man.
The two ships smash together like great wooden titans. Everything shudders and everyone except character falls to the deck. Character was impaled by a splintering piece of the ship for damage and is being held in place by that large splinter. He/she must must succeed at a constitution roll or be stunned for 1d10 rounds.
A massive strike to the hull has caused the cargo to shift and the ship to pitch wildly to starboard. Water pours through the damaged hull. Character takes damage when he/she is slammed by the shifting cargo. The player must also succeed at a strength roll or be trapped under the cargo in a hold filling with water.