I'm thinking about women in particular here, since I imagine it must have been a very male-dominated environment. Did they face a lot of harassment? Also, was socializing with the crew permitted? And if not, what did they do for fun?
I think it's important to note that in the context of the song, the Captain's Daughter is an instrument of punishment, be it rod or whip. Being drunk on duty, or disruptively drunk off was commonly punished with flogging.
As for taking families onboard a ship, I can't speak for merchant ships, I can speak with more certainty of commissioned ships of the Royal Navy.
Officially, the Admiralty forbade women onboard a man of war:
...He is not to allow of any woman being carried to Sea in the Ship; nor of any Foreigners, who are Officers or Gentlemen, being received on board the Ship, either as passengers, or as part of the crew, without orders from his Superior Officers, or the Lords Commissioners of the Admiralty...
Article XIV from Regulations and Instructions Relating to His Majesty's Service at Sea
However, like many of the regulations in the Royal Navy, it would often be bent or broken altogether. A ship dispatched to the Mediterranean Station might for instance carry the wife of another captain already on the station, though traveling via a merchant vessel would likely be preferable and more comfortable.
Some captains would take their wives or mistresses aboard on voyages, though it was more common to only take them so far as they followed the coast or to their new posting. Sea voyages in the Age of Sail were often dangerous and uncomfortable. Ships would be wrecked ashore, lost in storms, lose their wind and run out of water or suffer scurvy. This doesn't take into account enemy action for ships of the Royal Navy. Plenty of reasons not to take your family to sea.
If they did bring their wife/mistress to sea, she would live in the captain's cabin, and would likely only socialise with the officers and her husband. Outside of basic courtesies, the common sailor wouldn't speak with the captain's wife without express invitation.
Going down the ranks, officers and warrant officers occasionally brought their wives to sea. If the Captain's wife had a cramped, uncomfortable existence in the cabin, an officer's wife had it far worse. She would share her hammock with her husband in a tiny cabin and share his rations. Once again, socialisation outside of the officer class would be minimal.
Duties performed by a wife at sea would be quite similar at sea as on shore. Mending her husband's uniform, for instance. But a role they often fulfilled was the duty of governess of the youngsters and junior midshipman of a warship. They'd teach them basic skills that they likely otherwise wouldn't be taught by officers and sailors.
Socialisation with the crew.
Would have been minimal. There was a very clear class system in the Royal Navy.
You've got the various hierarchies and ranks within the common sailors, from lowly lubbers to the able seaman, often with less formalised hierarchies within each division. While there would be more respect shown to an experienced able seaman, socialisation among this class was normal.
Then you've got the Young Gentlemen, ranging from youngsters on their first voyage at the age of 12. These would be servants to officers, as they began learning their trade. After a few years they would be rated as a Midshipman, where they would serve until they passed for Lieutenant, or failing that, became Master's Mates, senior to other midshipmen, but hadn't earned their commission. This class was above the common sailor. An able seaman could be flogged for failing to show proper respect to a midshipman of just 15. Here is where socialisation with the officer's wives would become more common, but still minimal.
After this you have the warrant officers and commissioned officers. These are those gentleman that have passed for Lieutenant, earning their commission and further increasing the divide from the common sailor. A sailor wouldn't dream of addressing an officer out of hand outside of extreme circumstances or long standing. Addressing an officer's wife would be even more of a crime. Warrant Officers (Masters, Gunner's etc) while not holding a commission, are in a similar level. They salute the Lieutenants and owe them respect, but they're still in that separate, august class of officers, as are their wives.
Above them all is the captain. King of this little floating kingdom. While officers get little cabins and the gun room for meals, he has the entire aft section of the ship. If the captain was on deck, the windward side of the quarterdeck was his right. This privilege would pass to his wife in measure. While a lieutenant might speak to her similarly to any formal occasion, the class divide is still there.
Fraternisation between each class is minimal outside of work related matters. Officer's could speak to the wives of the same "class" as them with only the basic social constraints of speaking to another man's wife, but wouldn't speak to the captain's wife without her initiating conversation, or express invitation.
Bringing families aboard.
Bringing a daughter aboard except for passage or a short voyage would be almost unthinkable. But sons were a different matter. A major factor in promotion was "interest". How many senior officers a prospective young gentleman was connected with. A common practice among captains in the Royal Navy was to have their sons entered into the books of vessels commanded by friends or former shipmates (another practice that was illegal, but generally accepted) to gain "seagoing experience" before they were of an age to actually join a ship.
One they were old enough, they'd join a ship as a young gentleman, usually on the ship of their father's former shipmate, or a relative where their education and safety (as far as it could be assured) would be valued. Occasionally they'd serve on the same ship as their father, though once again, this would be frowned upon by some admirals and fellow captains.
Because I ramble a bit and probably am not extremely clear.
It's not unheard of for captains in the Royal Navy to bring wives aboard for long voyages, and families for shorter voyages, it wasn't common. Fraternisation between the different classes (Sailors, Young Gentlemen, Officers and Warrant Officers and the Captain) was minimal outside of specific social events, and even then was constrained by the social norms of the era. Socialisation with the crew would have been minimal. A possible comparison would be servants and a lady.
They'd often take on the role of teaching the youngsters and do the usual household stuff for their husband (though once again, constrained by the limitations of life aboard a ship).
Harassing the wife of an officer on a ship would be punished as severely as disrespecting her husband. If the sailor is lucky, he'll get away with a few lashes (...being put in bed with the captain's daughter) or dozens.
As for fun, I imagine they'd do whatever a woman would do for fun in that era while being confined. This particular part isn't my area to expand on, but embroidery/sewing, music and reading come to mind.
I made a reddit account just to respond to this, so fingers crossed this isn’t deleted for coming from a new account. (PhD student in musicology studying sea shanties)
Royal Navy vs. Merchants
I think it’s important to note off the bat that, in general, sailors in the Royal Navy were not the sailors singing sea shanties like “What shall we do with a drunken sailor.” Indeed, the Royal Navy usually did not even allow sailors to sing sea shanties as they worked. Like most things in history, there are obviously exceptions to this—certain songs were allowed in very specific contexts (forebitters/forecastle shanties (fo’c’sle if you want to be fancy) were songs sung during moments of leisure to just pass the time and are the main examples that come to mind), but in general, when we’re talking about sea shanties, we’re talking about traditions that were practiced by sailors aboard merchant ships. As such, the rules and conventions of merchant ships are of utmost relevance to this question.
Did merchant captains bring their families with them? (yes)
There are many instances of captains bringing their wives and children with them on their voyages for months (or years, depending on the length/type of commission) at a time. To reference one very prototypical example, Joanna Colcord (one of the most famous female collectors of sea shanties—she published a very popular and widely circulated collection in the early 20th century (Roll and Go!: Songs of American Sailormen)) was not only born aboard her father’s merchant ship (in 1882), but essentially grew up traveling the world with her family. (She only really moved off the ship when it came time to go to college.) This was not an unusual situation for merchant ships. If you read the family’s letters and journals, they reference many other families on many other merchant ships that they interact with at various ports throughout the world. (Parker Bishop Albee Jr. compiled a number of their letters/writing in a very readable book called Letters from the Sea, 1882-1901. It offers a vivid picture of what life was like at sea aboard these types of ships, complete with an unusually awesome amount of photographs.) Families aboard merchant ships of this time often had not only a single cabin at their disposal, but a collection of them. (Some families, like the Colcords, even had pianos on board!) They read, did their lessons (if they were children), played games, sewed and crafted, practiced singing/musical instruments, kept up with their journaling and correspondence, etc. When they were at port, they would go on trips to socialize or shop or sightsee on land, they would visit their friends’ ships, visit the local peoples. (In many ways, they had a normal life—it was just confined to a smaller area some of the time).
Socialization with the crew
An-Anaithnid is right that socialization with most of the crew would have been minimal. The family’s rooms would be in a separate part of the ship that would be largely off limits for most of the crew (and the wife/children were told they shouldn’t really venture into other areas of the ship). The ship’s main officers might have dinner with the captain and his family, but this would take place in the family’s part of the ship.
The crew also often had rapid turnover, especially in later years (late 19thc/early 20thc). If you read letters/journals/articles from captains of this time, they often lament how hard it is to find a reliable and consistent long-term crew. (Conditions were less than ideal and the pay wasn’t great.) If there was harassment, crew members might be punished and/or simply left at the next port.
Why are we talking about so late a time period (late nineteenth/early twentieth century)?
I also think it’s worth mentioning that, despite the common assumption that sea shanties are quite ancient, a lot of the songs we know and love today are relatively recent (nineteenth-century-ish—on the tail end of what one might consider the “Age of Sail”). To some extent, there is some validity in that belief in that many ancient cultures all over the world often had some sort of musical tradition where they had a type of rhythm going during labor at sea (which is at its core the essence of a sea shanty). However, we don’t really have much in the way of written record left over from these traditions. We’re mostly left with vague or passing references in a text—and can almost forget about having an actual musical score transcribed from much earlier than the 19thc when there was an explosion in musical literacy—although again, there are exceptions to this (see Laura Alexandrine Smith’s Music of the Waters (1888) for some examples).
Which is all to say, most of the shanties we know are from this nineteenth-century onwards period. Which means that a lot of the concerns about shipboard life/safety that An_anaithnid fairly points to were perhaps not as big of a concern (deepwater sailing got much much safer once we get to the nineteenth century). Sailing in general became a much safer pursuit, and families thus did not have to worry as much about sinking/drowning/pirates/whatnot.
“Captain’s Daughter”?
I wanted to end with the comment that, while the “captain’s daughter” might have been an instrument of punishment on some ships, that doesn’t mean it necessarily was so on all of them. Sailors are/were not a unified people group, and different terms meant different things to different crews. “Put him in bed with the captain’s daughter” might have been a threat on one vessel and a scandalous/humorous suggestion on another (or it could have meant both simultaneously).