In the Spring and Autumn Period, a man in the State of Jin took a fancy to a bronze bell and wanted to steal it. The bell was too large and heavy to be moved away, so he decided to smash it to pieces. But when his hammer struck the bell, it gave out a deep booming sound. Fearing that he might be heard, he covered his ears, and carried on with the work.
This idiom comes from the above story. It is used to satirize those who they are smart but only deceive themselves.