The modern meaning is to let out a secret that someone else was trying to keep. It originated as part of a confidence scam in the Medieval period in which piglets were sold at market, pre-bagged to keep them from running off. A dishonest man might have a few piglets in bags for show, and sell them, but when the exchange came, actually hand off cats in bags for coin. Letting the cat out of the bag is the moment you learned you'd been scammed, or more generally, that you learned a secret.
It probably has its origin in much the same roots as the phrase: "Buy a pig in a poke." A cat was substituted for a pig, chicken or some other kind of meat when a medieval customer made his or her purchase - but if the cat was let out of the bag, the jig would be up, as it were.
When a cat comes out of the bag one would imagine it had been kept in there against its will. When it came out, bang it would be a big deal and so if you use this expression something big is about to be released.