As far as the word “jig” is concerned, whatever its origin it seems to have been a very old term for a happy and lively dance, probably a dance commonly known throughout all western Europe fifteen centuries or more ago.
But in England, around 1600, the term “jig” became also a slang term for a practical joke, a bit of trickery.
When the victim of a practical joke discovers the trickery, he is no longer fooled. Nowadays he would say, “I’m on to you,” or, “I’m wise.”
The old expression was, “The jig is up,” and we have used it since with the general meaning, the trickery is exposed, the time for settlement has come.