To reveal a secret, unintentionally or otherwise.
Humorist and writer Will Rogers once said, “Letting the cat out of the bag is a whole lot easier than putting it back in.” Once a secret is out, there’s no way of reversing the process.
The first documented use of the phrase comes from a book review in a 1760 issue of The London Magazine, the reviewer lamenting that, "We could have wished that the author had not let the cat out of the bag." There are two main theories explaining where the phrase actually originated but neither is very plausible.
The first claims the phrase refers to the cat o’ nine tails, used by the Royal Navy as an instrument of punishment aboard its ships. The whip’s nine knotted cords could badly scratch a sailor’s back, like a cat’s claws. The bag comes into play because the “cat,” being made of leather, was kept in a sack to protect it from drying out and losing its flexibility. The “cat” may have been stored in a bag, but taking it out doesn’t match the ‘disclose a secret’ meaning of the phrase.
The other explanation says that the phrase came from livestock fraud. Supposedly, merchants would sell customers live piglets which were stored in bags for easy transport. The buyer wouldn’t discover they’d been cheated until they got home and a cat popped out of the bag. Piglets are bigger and heavier than cats and they make very different sounds. I can’t imagine enough people being fooled by this to give rise to an idiom. However, it may have arisen from the homily 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). In other words, “let the buyer beware.”
So there’s no clear answer as to where the saying came from. Possibly "letting the cat out of the bag" was never more than an entertaining image of what happens when an interesting secret is revealed. The shock and surprise when such truth is revealed could be compared to the commotion raised by a frightened cat suddenly loosed from the bag that imprisoned it. Or perhaps it comes from the fact that when either secrets or cats are let out, they go wherever they want.