Maintaining hygienic practices on a pirate ship was difficult. Lack of access to clean water, combined with confined living spaces, led to the rapid spread of disease. Insects like spiders and lice, and vermin such as rats, were impossible to keep off the ships. Harsh elements and inadequate nutrition further contributed to generally poor health. Bathing, laundry, and dental care were at a minimum.
Pirates were known to have bad teeth. If a pirate did take care of his teeth it was probably with a Chew Stick. Chew Sticks date back to ancient times and had medicinal properties.
If a Pirate bathed, they had to use seawater because freshwater was kept for drinking. Because of their superstitious fear of sea monsters, most likely they did not jump in the ocean, but used a bucket and sponge. Pirates wore the same clothes for months on end. It is likely they waited to wash clothing until they made port.
Pirates would go to the bathroom by climbing down on to the deck directly under the Bow Sprit and either poo or pee through the grates, just above the water line. Larger ships had “seats of ease” - toilets in the same place. The Bow is in the front of the ship or in the head of the ship. That maybe where the name Ships Head originated. Instead of Toilet Paper there was a long, poo-smeared rope that snaked through the hole in the Seats of Ease. The frayed end of the rope dangled in the sea and could be hauled up and used to wipe oneself clean.
Officers would use the Privy located in the stern overhang or use a Chamber Pot in the cabin.
As for shaving and haircuts steel razors had only recently been invented and were expensive. Poorer men shaved themselves with iron blades, or plucked the individual hairs with crude tweezers. If you did want a good shave or haircut you would visit the Ships Surgeon, who doubled as the Barber. Contrary to the unkept look of Blackbeard, the fashion at that time was generally for men to be clean-shaven.