A boatswain is a petty officer on a ship. The boatswain supervises the crew.
A swain was someone who attended to the needs of a medieval knight. Similarly, a boatswain attends to the needs of a boat by being in charge of the crew and making sure they get work done. The captain is in charge of the boat, but the boatswain is in charge of work done on the boat, just as the cook is in charge of the kitchen. The boatswain is also responsible for equipment on the boat.