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.