WebMD explains that the primary purpose of mucus is to coat the passageways of the nose, throat, sinuses, lungs and gastrointestinal tract and keep them from becoming dry. If these passages dried out, their surfaces could crack, potentially providing pathogens with an entryway into the body. Additionally, the mucus lining these structures traps and contains dirt and other foreign particles so that they do not reach the lungs.
Mucus also contains antibodies that recognize invading organisms, such as viruses and bacteria. After the bacteria or viruses have been identified and trapped in the mucus, enzymes in the fluid kill the invaders. WebMD explains that mucus also helps to defend the body while it is sick, by producing more mucus. The reason most people notice their mucus when they are sick is that the mucus changes consistency, becoming much thicker than usual.
In addition to illness, mucus production may increase when people eat spicy foods, a condition called gustatory rhinitis, according to WebMD. This reflex reaction causes the noses of people who eat hot peppers and other acidic foods to run. Conversely, milk, which is not acidic, also elicits a similar reaction in some people. Allergens, such as pet dander and pollen may also cause the body to produce more mucus.