The gut and the immune system.
A whopping 70-80% of your immune system resides in the gut, and the gut microbiome and the immune system work in harmony with one another.
The gut microbes help to regulate your immune system, and your immune system helps your body form a healthy balance of microbes. “What’s present in the gut determines what education immune cells get." - David Herber, MD, PhD, professor at UCLA Health.
So to summarise, your gut health plays an important role in your immune system.
Another angle to consider is the immune response caused by damage to the lining of your gut.
To keep it simple: Gut dysbiosis (an imbalance of good and bad bacteria) > makes holes in the gut wall (the epithelial layer that's one cell thick) by breaking the "tight junctions" that hold it together > things seep through that shouldn't = immune response.
This "breaking of the gut wall" is otherwise called leaky gut, or increased intestinal permeability.
Now what breaks through is called bacterial endotoxin, and this activates the immune system. Dr. Will Bulsiewicz describes bacterial endotoxin as the simplest way to visualise inflammation - with inflammation linked to a host of health issues. (skip to 58:45 - a great podcast to watch)
Without delving too deeply, I hope this gives you some context on how important maintaining your gut health is to not just the way your stomach feels and how you digest foods, but all corners of your health and wellbeing - including your immune system.