Solution 1:

The 1811 Dictionary in the Vulgar Tongue, by Francis Grose defines shag as:

To SHAG. To copulate. He is but bad shag; he is no able woman's man.

In the same dictionary there is the seemingly unrelated term church warden which Grouse writes:

A Sussex name fora shag, or cormorant, probably from its voracity.

Cormorant and shag is the name of a type of seabird, the terms are mostly interchangeable although ornithologists will make the distinction between the Great Cormorant, a British seabird, and the European Shag (also present along the UK coastline) so-called due to the appearance of a crest during the mating season. The European Shag is well-known for its voracious appetite and is capable of diving at least 45 metres for anything up to 45 seconds in order to catch its prey.

Shags are opportunists, feeding on a wide range of benthic, demersal and schooling, pelagic fish. Source

-----------enter image description here
For info on the European Shag see: Sexual ornament size and breeding performance in female and male European Shags
and Wikipedia.

The Oxford Concise English Dictionary dates the term shag from C16th

Shag n. a cormorant with greenish-black plumage and a long curly crest in the breeding season. [Phalacrocorax aristotelis.] Origin C16: perh. a use of 'shag', with ref. to the bird's 'shaggy' crest.

Oxford Dictionaries tells us that sexual meaning of shag could be derived from Old English sceacan for shake and quake.

Shag as in shag pile carpet was sceacga ‘rough matted hair’ in Old English. Of Germanic origin, it is related to Old Norse skegg ‘beard’. The mid 16th-century bird name shag is perhaps a specific use of the word, with reference to the bird's ‘shaggy’ crest. The use of the verb to mean sexual intercourse is first recorded in 1788, but is probably older. It may go back to an older verb meaning ‘shake’ (which may be the origin of shag) which is recorded between the 14th and 16th centuries.

When one partner energetically shags another, it's certainly true that their bodies toss and turn, moving to and fro rapidly, either one may experience a trembling sensation, and the orgiastic line: Did the earth move for you? may be uttered. Although that particular expression was coined by Ernest Hemmingway in 1940, the concept of something being so forceful, so powerful that it causes the Earth to shake is as old as time immemorial.


Americans were “shagging” before 1999

I've been watching the entire 11 seasons of Cheers, 1982 to 1993. As luck would have it, I've come across shag being used for the first time in the hit TV sitcom show; season 11, episode 25, The Guy Can't Help It, which aired May 13, 1993. Now I've heard the term boink being uttered a couple of times in the show, especially by Carla, the bar's waitress, but never shag. Not until this episode: Sam Malone, the charismatic and highly-sexed owner of Cheers, a Boston bar, has reluctantly agreed to see a sex therapist. In the first group therapy he attends he admits

Sam Malone 19.24: I don't know what the big deal is. You know, when I was growing up, it was a sign of manhood how many women you shagged. I guess I just missed the announcement when they changed the rule. So I just, kept on doing it.

Solution 2:

Well, it's the fourth definition given on Merriam-Webster for "shag", and under origin, it says:

Origin of SHAG earlier argot, probably ultimately from Middle English shoggen, shaggen to shake — more at shog. First Known Use: 1788

http://www.merriam-webster.com/dictionary/shag

and for shog (to shake, jolt, or move in a jerky manner), M-W states of its origins:

Middle English shoggen, shaggen; probably akin to Middle Dutch schocken to shake, jolt First Known Use: 15th century

http://www.merriam-webster.com/dictionary/shog