In the days when human muscles were the only power source available aboard ship, shanties served practical functions. The rhythm of the song served to synchronize the movements of the sailors or to pace the labor as they toiled at repetitive tasks. Singing helped to alleviate boredom and to lighten, perhaps, the psychological burden of hard work. Shanties may also be said to have served a social purpose, as to build camaraderie.
(text by wikipedia)