Hanky-panky, a synonym for trickery, was first recorded in 1841 in the British humor magazine Punch. It may have been coined from the slight-of-hand of a magician.
The word probably has its origins in the jargon of fairs and carnivals. It was there that magicians learned to keep their audience's eyes off their doings with a distraction like an umbrella or a handkerchief. It was more often the hanky under which so many things would mysteriously appear or disappear.
This practice was so common that the expression came to be associated with any clandestine activity, undercover doings, double-dealing, or devious trickery.
Hanky-panky is much younger than another carnival term hocus-pocus and may have been inspired by it.
These days, anything low-brow or cheap may be called sleazy especially anything contemptible, mean, or disreputable. Why?
At one time, the name referred specifically to a particular kind of flimsy linen manufactured in Silesia, a German province. This special linen was attractive to English merchants for purely economic reasons. They could buy a load of it cheaply, sell it inexpensively, and still make good money.
A lot of substandard linen was sold before consumers caught on to the shoddiness of the merchandise. Under a trade name "sleazy Holland," it eventually became so well known that over the centuries its name extended to anything inferior or poorly made.
This expression has nothing to do with folding socks, but it does have to do with shoes. Horseshoes, that is.
Years ago, dashing through the snow in a horse-drawn sleigh had its hazards. Balls of snow or ice would form under a horse's hoof and could cause the animal to slip and fall, taking down the rest of the team and even tipping over the sleigh.
This term for some pretty helpless wintertime confusion has since given rise to mean any mixed-up situation.
Sources: 'Why You Say It' by Webb Garrison; 'Morris Dictionary of Word and Phrase Origins,' by W. and M. Morris; 'The Encyclopedia of Word and Phrase Origins,' by Robert Hendrickson; The Oxford Dictionary; 'The Barnhart Dictionary of Etymology,' by Robert Barnhart'; 'Horsefeathers,' by Charles Funk; 'Have a Nice Day,' by C. Ammer; 'Picturesque Expressions,' by Urdang, Hunisnger, and LaRoche.