I guess they managed to wriggle in at the factory -- or maybe the eggs were on the onions and somehow survived the journey into powder? And then they hatched/lived in this bottle of onion powder for six months or more? And when I used the onion powder before, on other occasions, we probably ingested their friends?
I'm more than a little grossed out thinking about how this situation possibly came to be. Especially after I read on Wikipedia that caterpillar hair can cause health problems ranging from "urticarial dermatitis and atopic asthma to osteochondritis, consumption coagulopathy, renal failure, and intracerebral hemorrhage." I don't even know what half those things are. Oh, and caterpillar hair can even cause death.
It brought to mind that Internet forward that was going around a few years ago that warned against drinking directly from aluminum cans, saying that the cans are usually stored for a period of time in warehouses where mice and rats have the opportunity to defecate on them, leading to you, the drinker, getting a fatal disease. I've just learned from Snopes that this tale is mostly not true (apparently the pee of a healthy rat is safe to drink!), but after finding caterpillars in your onion powder, it really makes you think.