Perhaps you've heard this slang term on The Three Stooges and wondered where it came from. Well, wonder no more!
Back in the days of the great sailing ships, when the decks were made of wood and the men were made of iron, the long days at sea wore on the poor sailors. In truth, many sailors in the 1700s and 1800s were impressed (kidnapped) into service, and desertion was a big concern. Naturally, the problem was compounded when the ship pulled into port. When the liberal application of rum, sodomy and the lash failed to improve morale, the crew was ultimately allowed conjugal visits aboard ship.
It has always been the case that after morning reveille sounds, all hands must report to their stations. If a sailor decided to sleep in, he would be unceremoniously yanked out of his bunk/hammock and disciplined. To avoid the embarrassment of pulling out someone's naked wife, whether by long practice or by order of some long forgotten officer, women were advised to "show a leg." Smooth, curvy legs were left alone; gnarly, hairy legs were given the old heave-ho.
Over time, the language got rearranged from "show a leg" to "shake a leg." Although the general meaning of the slang term today is to "hurry up and get going," it is interesting that the tradition lives on in the modern Navy. Sometimes separate berthing for different shifts is not possible, and day sleepers, meaning those normally working night shift, are encouraged to show a leg to avoid being roused by the watch.