"crazy, not right in the head," 1846, from earlier colloquial or slang be nuts on "be very fond of" (1785), which is possibly from nuts (plural noun) "any source of pleasure or delight" (1610s), from nut (q.v.). Nuts as a special treat or favorite foodstuff led to other figurative phrases, now obsolete. The "crazy" sense probably has been influenced by metaphoric application of nut to "head" (1846, as in to be off one's nut "be insane," 1860). Also compare nutty. Nuts as a derisive retort is attested from 1931.
Connection with the slang "testicles" sense has tended to nudge the word toward taboo territory. "On the N.B.C. network, it is forbidden to call any character a nut; you have to call him a screwball." [New Yorker, Dec. 23, 1950] "Please eliminate the expression 'nuts to you' from Egbert's speech." [Request from the Hays Office regarding the script of "The Bank Dick," 1940] This desire for avoidance probably accounts for the euphemism nerts (c. 1925).
also nerts, 1932, originally American English college slang, colloquial or euphemistic pronunciation of nuts as a slang retort of defiance or dismissal (1931).
early 15c., "nut-like," from nut (n.) + -y (2); from 1660s as "abounding in nuts." Sense of "having the flavor of nuts" is by 1828. Slang meaning "crazy" is by 1898 (see nuts); earlier colloquial sense was "amorous, in love (with)," 1821. [Byron, in a slangy passage in "Don Juan" (1823) uses it of a beggar's doxy; a footnote defines it as "conjointly, amorous and fascinating."] Related: Nuttiness.
"the fruit of certain trees and shrubs which have the seed enclosed in a woody covering not opening when ripe," Middle English note, from Old English hnutu, from Proto-Germanic *hnut- (source also of Old Norse hnot, Dutch noot, Old High German hnuz, German Nuss "nut"), from PIE *kneu- "nut" (source also of Latin nux; see nucleus).
Sense of "testicle" is attested by 1915 (nuts). Nut-brown "brown as a ripe, dried nut" is from c. 1300 of animals; c. 1500 of complexions of women. The mechanical nut that goes onto a bolt is first recorded 1610s, from some fancied resemblance (nut was used of other small mechanical pieces since early 15c.). The figurative nuts and bolts "fundamentals" is by 1952. The American English slang sense of "amount of money required for something" is recorded by 1912.
Meaning "crazy person, crank" is attested from 1903; British form nutter is attested by 1958. Nut-case "crazy person" is from 1959; nut-house "insane asylum" is by 1929. For more on this sense, see nuts. In slang, nut also meant "fashionable or showy young man of affected elegance" [OED], 1904.
"action of gathering nuts," 1723, verbal noun from nut (v.) "to gather nuts" (c. 1600), from nut (n.).