https://directorsblog.nih.gov/2017/01/10/peanut-allergy-earl...
Similar to germ theory, some exposure is actually good.
If our immune systems and bodies were all-knowing and perfect, then sure, that would be a valid assumption, but they're far from it.
Nature can be dangerous, too, but at least it's likely that someone in the past has dealt with it and lived to reproduce.
With new synthetic substances, you're essentially doing alpha-testing with your irreplaceable hardware/software system...
Turns out I'm allergic to some trees, some grasses, pollen, mold, dust mites, and a bunch of other things. And yet my childhood from a very young age was filled with playing outside in the yard and and in the woods.
Also my family had (indoor-only) cats since before I was born. My parents were allergic to them, and my sister and I are also allergic. (Wanting to get a cat is what prompted me to start the allergy shots.) So I've been exposed to cat dander since I was an infant. And yet: allergic. Some things are just hereditary, I guess.
I'm sure there are some cases where not being exposed to something when young can cause you to develop allergies, but that's definitely not the only cause. Seems like there is definitely a genetic component that can moot any amount of childhood exposure.
I don't know why people become allergic to them, but there must be something in some peanuts which sets off their immune system.