The first time the phrase pop goes the weasel was first recorded in print was in an 1853 edition of the London Times to describe the children's game, but it was almost certainly used colloquially for a substantial period before that. It seems that the words were added to an existing dance tune at some point during the nineteenth century, but the exact etymology is debated. One of the main theories is that pop goes the weasel traces to Cockney rhyming slang, where pop meant "to pawn" or "barter away" and weasel was a type of coat. In the context of the third verse of the song, half a pound of tupenny rice/half a pound of treacle/that's the way the money goes/pop goes the weasel, this would refer to someone spending all their money on food and having to pawn away their best jacket. Later on, this would become confused with the animal weasel, which would explain the other verses. Alternatively, the weasel here could be a spinner's tool used for measurement, which made loud popping sounds after every fortieth revolution, and it apparently also meant "flat iron". You'll have to judge the plausibility of those proposals yourself.
Hello! I'm Adam Aleksic, a sophomore studying government and linguistics at Harvard University, where I co-founded the Harvard Undergraduate Linguistics Society. In addition to etymology, I also really enjoy politics, vexillology, geography, board games, conlanging, and law.