For me, it was hornets.

One summer afternoon when I was 12, I ran into an overgrown field near a friend’s house and kicked a hornet nest the size of a football. An angry squadron of insects clamped onto my leg; their stings felt like scorching needles. I swatted the hornets away and ran for help, but within minutes I realised something else was happening. A constellation of pink stars had appeared around the stings. The hives swelled, and new ones began appearing farther up my legs. I was having an allergic reaction.

My friend’s mother gave me antihistamines and loaded me into her van. We set out for the county hospital, my dread growing as we drove. I was vaguely aware of the horrible things that can happen when allergies run amok. I imagined the hives reaching my throat and sealing it shut.

I lived to tell the tale: my hives subsided at the hospital, leaving behind a lingering fear of hornets. But an allergy test confirmed that I was sensitive to the insects. Not to honey bees or wasps or yellow jackets. Just the particular type of hornet that had stung me. The emergency room doctor said I might not be so fortunate the next time I encountered a nest of them. She handed me an EpiPen and told me to ram the syringe into my thigh if I was stung again. The epinephrine would raise my blood pressure, open my airway – and perhaps save my life. I’ve been lucky: that afternoon was 35 years ago, and I haven’t encountered a hornet’s nest since. I lost track of that EpiPen years ago.

Anyone with an allergy has their origin story, a tale of how they discovered that their immune system goes haywire when some arbitrarily particular molecule gets into their body. There are hundreds of millions of these stories. In the USA alone, an estimated 18 million people suffer from hay fever, and food allergies affect millions of American children. The prevalence of allergies in many other countries is rising. The list of allergens includes – but is not limited to – latex, gold, pollen (ragweed, cockleweed and pigweed are especially bad), penicillin, insect venom, peanuts, papayas, jellyfish stings, perfume, eggs, the faeces of house mites, pecans, salmon, beef and nickel.

Once these substances trigger an allergy, the symptoms can run the gamut from annoying to deadly. Hives appear, lips swell. Hay fever brings sniffles and stinging eyes; allergies to food can cause vomiting and diarrhoea. For an unlucky minority, allergies can trigger a potentially fatal whole-body reaction known as anaphylactic shock.

The collective burden of these woes is tremendous, yet the treatment options are limited. EpiPens save lives, but the available long-term treatments offer mixed results to those exhausted by an allergy to mould or the annual release of pollen. Antihistamines can often reduce sufferers’ symptoms, but these drugs also cause drowsiness, as do some other treatments.

We might have more effective treatments if scientists understood allergies, but a maddening web of causes underlies allergic reactions. Cells are aroused, chemicals released, signals relayed. Scientists have only partially mapped the process. And there’s an even bigger mystery underlying this biochemical web: why do we even get allergies at all?

“That is exactly the problem I love,” Ruslan Medzhitov told me recently. “It’s very big, it’s very fundamental, and completely unknown.”

Medzhitov and I were wandering through his laboratory, which is located on the top floor of the Anlyan Center for Medical Research and Education at the Yale School of Medicine. His team of postdocs and graduate students were wedged tight among man-sized tanks of oxygen and incubators full of immune cells. “It’s a mess, but a productive mess,” he said with a shrug. Medzhitov has a boxer’s face – massive, circular, with a broad, flat nose – but he spoke with a soft elegance.

Medzhitov’s mess has been exceptionally productive. Over the past 20 years, he has made fundamental discoveries about the immune system, for which he has been awarded a string of major prizes. Last year he was the first recipient of the €4 million Else Kröner Fresenius Award. And though Medzhitov hasn’t won a Nobel, many of his peers think he should have: in 2011, 26 leading immunologists wrote to Nature protesting that Medzhitov’s research had been overlooked for the prize.

Now Medzhitov is turning his attention to a question that could change immunology yet again: why do we get allergies? No one has a firm answer, but what is arguably the leading theory suggests that allergies are a misfiring of a defence against parasitic worms. In the industrialised world, where such infections are rare, this system reacts in an exaggerated fashion to harmless targets, making us miserable in the process.

Medzhitov thinks that’s wrong. Allergies are not simply a biological blunder. Instead, they’re an essential defence against noxious chemicals – a defence that has served our ancestors for tens of millions of years and continues to do so today. It’s a controversial theory, Medzhitov acknowledges. But he’s also confident that history will prove him right. “I think the field will go around in that stage where there’s a lot of resistance to the idea,” he told me. “Until everybody says, ‘Oh yeah, it’s obvious. Of course it works that way.’”