1590s, an abusive term for a person, perhaps meaning "a pedant;" c. 1600, "a whim;" 1640s, "pun or word-play," a word of unknown origin, said in 17c. to be Oxford University slang. Perhaps the sort of ponderous mock-Latin word that was once the height of humor in learned circles; Skeat suggests Latin conandrum "a thing to be attempted" as the source. Also spelled quonundrum.
From 1745 as "a riddle in which some odd resemblance is proposed between things quite unlike, the answer often involving a pun." (An example from 1745: "Why is a Sash-Window like a Woman in Labour? because 'tis full of Panes").