This idiom has to do with telling a secret. When you let the cat out of the bag, you tell something that is not public or something that was not previously.
Example:
I didn’t mean to let the cat out of the bag and tell her about her birthday surprise.