late 15c., probably an unexplained variant of Middle English maðek, from Old English maða "maggot, grub," from Proto-Germanic *mathon (cf. Old Norse maðkr, Old Saxon matho, Middle Dutch, Dutch made, Old High German mado, German Made, Gothic maþa "maggot"). Figurative use "whim, fancy, crotchet" is 1620s, from the notion of a maggot in the brain.
maggot mag·got (māg'ət)
The legless, soft-bodied, wormlike larva of any of various flies of the order Diptera, often found in decaying matter.