The earliest recorded use of the phrase appeared in 'TheTimes' in the early 1960s, though it probably existed in speech prior to that time. It means that you are exposing 'a mass of troubles', all entangled with each other, in the same way as you would find worms wriggling and almost inextricably entwined in a can. Always best to leave the can closed!