booby (n.)
"stupid person," 1590s, from Spanish bobo "stupid person," also used of various ungainly seabirds, probably from Latin balbus "stammering," from an imitative root (see barbarian).

Specific sense "dunce in a school class" is by 1825. Booby prize "object of little value given to the loser of a game," is by 1883:
At the end of every session the dominie had the satirical custom of presenting his tawse [a corporal punishment implement used for educational discipline] as a "booby-prize" to some idle or stupid lout whom he picked out as meriting this distinction so that next time they met he might start fresh and fair with new pair for a new set of classes. [Ascott R. Hope, "Dumps," "Young England" magazine, 1883]
Booby trap is by 1850, originally a schoolboy prank; the more lethal sense developed during World War I. Booby-hatch "wooden framework used to cover the after-hatch on merchant vessels" is from 1840; as "insane asylum" by 1936.