Many idioms have a basis in literature. If you are well read, you will understand the reference in the idiom and thus the meaning. In particular, Shakespeare, Mark Twain and the King James version of the Bible are rich sources. Other idioms are quotations from famous people. The internet is full of quotation websites where you can read these quote. Reading biographies of famous people such as Churchill and Gandhi will give you the background to many idioms that they coined. Some idioms come from popular culture. Watch movies and listen to English music. Especially older movies and music rather than modern ones. For example, Casablanca, Lawrence of Arabia, Spartacus, The Godfather, The Wizard of Oz, Clockwork Orange, One Flew Over the Cuckoo’s Nest, etc.