How did "hearties" come to mean "shipmates"?

Solution 1:

The OED says

A hearty fellow; a brave, vigorous man; esp. in phr. my hearty!, my hearties! used in addressing sailors. Hence, a sailor, a jack-tar.

No mention of sea-shanties, and no suggestion that the "hearty work" accompanied by them had any particular relevance. Once again it is a fairly transparent use of a word which to my mind doesn't require any special explanation.

But it clearly is associated with the sea from the beginning: the earliest citation is from Phantom Ship by F Marryat in 1839.

Solution 2:

I believe this comes from similar roots as the tradition of sea shanties:

In the days when human muscles were the only power source available aboard ship, sea shanties served a practical purpose: the rhythm of the song served to synchronize the movements of the sailors as they toiled at repetitive tasks. They also served a social purpose: some find singing and listening to songs to be pleasant, and for these people it alleviates boredom and lightens the burden of hard work, of which there was no shortage on long voyages in those days.

There's plenty of references to hearties as workmates in sea shanties: the sailors are performing hearty work.

From Act I, Scene I of Shakespeare's The Tempest:

Boatswain
Heigh, my hearts! cheerly, cheerly, my hearts! yare, yare! Take in the topsail. Tend to the master's whistle. Blow, till thou burst thy wind, if room enough!

The sailors are being encouraged on to happily and joyfully use their hearts to perform this hearty work.