stinging insect, Old English beo "bee," from Proto-Germanic *bion (cf. Old Norse by, Old High German bia, Middle Dutch bie), possibly from PIE root *bhi- "quiver." Used metaphorically for "busy worker" since 1530s.
Sense of "meeting of neighbors to unite their labor for the benefit of one of their number," 1769, American English, probably is from comparison to the social activity of the insect; this was extended to other senses (e.g. spelling bee, first attested 1809; Raising-bee (1814) for building construction; also hanging bee "a lynching"). To have a bee in (one's) bonnet (1825), said of one who is harebrained or has an intense new notion or fancy, is said in Jamieson to be Scottish, perhaps from earlier expressions such as head full of bees (1510s), denoting mad mental activity.
BEE IN one's BONNET (mid-1800s+)