The trick may have been practiced in the time of the Pharaohs; if not, probably some variant of it was.
Certainly someone then knew that the hand is quicker than the eye.
In England it was known as “the thimble trick” two and a half centuries ago, and then, as now, the trickster at horserace or fair would exhibit a pea and three thimbles or small cups, then, at first with modest wager, challenge a bystander to guess under which thimble he had hidden the pea.
A hundred years later, when rig became a slang term for “to cheat or trick,” our present word thimblerig came into use, and it was, of course, a simple step to transfer the application to any form of trickery or jugglery.