Anatomically speaking the body’s ‘city walls’ have a range of effective sentries. Hairs in the nose and on the eyes prevent particles of dirt and dust etc getting into places they shouldn’t be. Tear ducts wash the eyes clean. Mucus is produced in the nose, nasal passages and pharynx (the bit beyond the nasal passage and above the tubes that go to the stomach and lungs). Mucus is full of good stuff, proteins and enzymes etc, that trap inhaled unwanted foreigners and get rid of them. The mucus also supports the cilia (tiny hairs that beat back and forth) that draw the mucus up and help remove the nasties in it.
The stomach and gut produce enzymes, gastric and bile acids, chemicals. proteins and micro-organisms to protect them against anything that shouldn’t be there. And should the something be a bit more indigestible, then peristalsis (wave action) will push it out.