It's based on the idea that a 'booby' is a stupid person...perhaps coming from the Spanish word 'bobo', meaning an idiot/dolt. It was originally applied to childish tricks such as putting something on top of a door so that it would fall on the head of someone who opened it. Nowadays, of course, it is a rather more serious device, generally intended to kill rather than just make you look silly.
Not really so, I'm afraid, Mje. The earliest recorded use of the word 'booby' in English quite clearly referred to the foolish person and not the bird. The bird took its name from the already-established silliness of certain people rather than vice versa.