This "bee" is apparently unrelated to the insect. At the link below it is given a separate etymology: "C18: perhaps from dialect bean neighbourly help, from Old English ben boon". In the phrase "spelling bee", "spelling" functions as a noun.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.