Claim: To "let the cat out of the bag" comes from cats being sold as pigs or sailors being whipped for transgressions.
Origins: To "let the cat out of the bag" is one of those sayings wherein meaning is instinctively grasped even if it's difficult to coherently put into words why this is so. While this phrase is a widespread shortform for truth coming to light, there is nothing obvious about why a cat's being released from a sack should have anything to do with a secret's being revealed. (Even so, it's a handy phrase to have in one's linguistic arsenal, in that there's no one word in the English language that conveys the revelation, deliberate or accidental, of information that was intended to be kept hush-hush.)
The most widely believed theory about the saying's origin asserts it has to do with chicanery practiced upon those purchasing livestock. According to its lights, unscrupulous sellers of pigs would hastily swap a cat for the porker that had been purchased and bagged for easier transport when the buyer looked away for a moment, with the duped purchaser discovering the substitution only upon returning home and letting the cat out of the bag.
Although numerous etymology books tout this explanation as the phrase's origin, common sense should serve to dismiss it. For the duped livestock purchaser theory to be right, the seller's deception would come to light only when the cat was let out of the bag. Yet, bag or not, it's nigh on impossible to mistake a cat for a pig. At very least, anyone this deception was tried upon would quickly conclude there was something mighty wrong about its porker long before he opened the bag to see what was going on inside.
Housecats and pigs are not of comparable size, so a sack containing the one instead of the other isn't going to fool a buyer, in that the filled bag is going to be a fair bit smaller than it was before the sleight of hand. Even if a large cat were shoved into the bag in place of a rather small pig, due to the nature of the build of each of these types of critters, the weight is going to be badly off — since cats are rather loosely constructed compared to far more densely-fleshed pigs, the cat is going to weigh far less than the porker even when both animals are the same size.
Cats also behave far differently than pigs. While a pig encased in a sack might squeal or oink as it's carried home, a cat is going to spit, yowl, hiss, and meow. We think you'd have to search high and low to find anyone capable of mistaking the sounds made by the one for the noises produced by the other. Moreover, while a pig in a bag might kick and struggle, a cat will add its signature claw work to that dynamic. As he regards his ripped-up appendages, even the most dense of livestock purchasers is going to realize that pigs don't have claws.
Last, consider this: For "let the cat out of the bag" to have as its origin a practice of cats being surreptitiously
foisted upon the unwary as pigs by crooked farmers, said fraud would have had to have been successfully run on so many that its denouement worked its way into the language (and that via folks not figuring out they'd been had until they got home). There weren't that many fools in the Middle Ages: if there had been, the species wouldn't have survived.
We suspect the duped livestock purchaser explanation was borrowed from the admonishment about not buying a pig in a poke, a saying that reliably dates to 1555 (with its antecedent "When a pig is offered, open the poke" dating to 1325). That homily cautions against buying goods one has not examined (as opposed to afterwards checking goods already examined and purchased to assure no one has covertly exchanged them for less valuable commodities).
A second theory ascribes the origin of the saying to the British Royal Navy, asserting the instrument of punishment used upon those errant in their duties or behaviors (a whip called the 'cat of nine tails' or 'cat-o'-nine-tails') was routinely kept in a red sack, thereby a sailor who brought to light the transgressions of another was "letting the cat out of the bag." However, no evidence documents that such whips were commonly stored in sacks, or that the phrase "let the cat out of the bag" was initially associated with maritime origins or usage.
As to where the saying did come from, there is as yet no clear answer. Possibly "letting the cat out of the bag" was always meant as no more than an entertaining mental image of the explosiveness of a confidence's revelation — usually what is deliberately concealed is of a salacious or titillating nature, thus there are often huge elements of shock and surprise when the truth comes out, somewhat akin to the commotion raised by a frightened cat suddenly loosed from the bag that had imprisoned it. Or it could have to do with a similarity between the behavior of both secrets and cats — once either is let out, they go wherever they want. (In other words, private news that has been made public spreads far and wide, despite all efforts to keep it contained to a small circle of confidantes or even to silence it altogether.) Or it could be that "let the cat out of the bag" was a line from a play now lost to us wherein the connection between moggies and sacks and secrets was all made clear to the audiences enthralled by it.