system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does our immune system decide what substances it should produce antibodies for?

I've been reading about red meat allergy from lone star ticks (on wikipedia) and read that the cause was supposedly from a substance from most mammals called alpha-gal entering the bloodstream and our body producing antibodies. These antibodies in turn make us allergic to alpha-gal when we eat it in our food.

I've gotten lemon juice in a cut before and I'm not allergic to lemons, so what makes our body decide to produce antibodies against specific substances in our bloodstream?
gpt
Your body makes antibodies completely randomly.

Imagine a child playing with some building blocks. Each B-Cell builds a little tower of blocks by randomly rearranging a special part of it's DNA when it develops. If the antibody it's made sticks to something that's "self", then it gets the message to stop making antibodies, and the cell dies and gets recycled.

The BCells which don't react to self then merrily wander around your bloodstream brandishing their antibody and seeing if it sticks to anything. If it finds something it sticks to, it goes to the spleen and asks around to see if any T-Cells think the thing it sticks to is foreign. If it gets the signal that it is, then the BCell reproduces a lot, and each child BCell randomly tweaks it's antibody blueprint by randomly mutating it's DNA.

These child BCells then compete to see who's antibody binds the thing they'be found best, and the process repeats until you've evolved a really good antibody which binds strongly to it.

If you get alpha-gal in your blood, you may or may not have a BCell who happens to have made an antibody which binds to it. The building blocks the BCells use to make their antibodies are inherited, so if you have a building block which already nearly binds the alpha-gal, you'll be more likely to have a BCell make an antibody against it than someone who doesn't have that building block.

If the BCell gets given the right messages from the T, it can decided that the thing it's killing is a *serious* threat. Then it does a process called *class switching* where it keeps the same antibody building blocks, but essentially sticks a landmine on the end. This is now an IgE antibody. The BCell will then produce this in large volumes, and the surrounding tissue cells will take it up and coat their surface with it. When the target approaches one of these cells, the IgE antibody will bind to it and trigger the land mine, creating a lot of inflammation and damage. This is what causes serious allergies to produce lots of swelling, and is naturally used to kill large, multi-cellular invaders such as parasitic worms. This is your bodies equivalent of "kill it with fire."