A practical joke. Also a concealed and possibly lethal trap.
Booby has been in use meaning dunce since at least the late 17th century. A 'booby trap' was originally understood to be a practical joke - not necessarily anything dangerous. These two citations from the 19th century indicate that:
Francis Smedley's Frank Fairlegh, or scenes from the life of a private pupil, 1850:
"The construction of what he called a 'booby-trap'."
The 1868 Chambers Journal:
"A 'booby-trap; - it consisted ... of books, boots, etc., balanced on the top of a door, which was left ajar, so that the first incomer got a solid shower-bath."
This meaning of 'booby trap' is similar to the notion of April Fool, that is, the joke was such that only a naive 'booby' would fall for it.
By the early 20th century things had got much more serious. By then, traps that could, and were intended to, kill were also called booby traps.
E. F. Wood, in Intelligence Officer, 1917:"'Booby' traps were sprinkled about the country in the form of bombs."
P. Gibbs, in From Bapaume to Passchendaele, 1918: "The enemy left 'booby-traps' to blow a man to bits or blind him for life if he touched a harmless-looking stick or opened the lid of a box."
See also - 'booby prize'.