The origin of the phrase "hanky panky" is uncertain, but there are several theories:
From "hank" and "pank": "Hank" refers to a coil of thread or yarn, while "pank" is a slang term for a prostitute. It suggests engaging in illicit or dubious activities, like a prostitute peddling her wares.
From "hankey pankey": "Hankey" is a colloquialism for handkerchief, and "pankey" is a synonym for "nonsense" or "foolishness." Thus, "hankey pankey" could refer to trivial or insignificant matters.
From "hangy-bangy": This phrase, meaning "rough play," could have been softened to "hanky panky" for euphemistic reasons.
From Hindi "haňk pâṅk": This Hindi expression means "to deceive, to hoodwink," which could have entered English through British colonial influence.
Meaning
"Hanky panky" has several related meanings:
Illicit or dubious behavior: Engagements that are considered inappropriate, secretive, or unethical.
Coquetry or flirtation: Amorous or flirtatious behavior, especially when considered improper.
Trivial or nonsense: Activities or discussions that are unimportant, irrelevant, or frivolous.
Origin
The exact origin of "hanky panky" is unknown, but it appeared in English literature in the early 18th century:
1707: "A Compleat Key to the Tale of a Tub": "Establishing their grand levee, where they now hold their hanky-panky assembly."
1738: Samuel Richardson, "Pamela": "I hope the good lady will not take it for hanky-panky, but for a mark of my civility."