Mucus is made by tiny glands in your sinus and nasal cavities. It is 95% water, but also includes proteins (that give it elasticity), fats, carbohydrates and salt. The healthy human nose makes more than a pint of mucus a day, which forms a blanket over the delicate tissue that lines the nose. Little hairs called cilia beat along the nasal passages to move the mucus around, and it drains down the back of the throat, where it is unknowingly swallowed.
Despite its tendency to become annoying at times, especially when you get a cold, mucus does a lot of good things for you. It keeps germs, dirt, pollen and bacteria from getting into your lungs by trapping them in your nose. When the mucus does not effectively clear out irritating particles your sinuses kick into high gear and produce even more mucus in an attempt to flush the nose out; this leads to a runny nose. If the invading particle is a virus or bacteria, your immune system may respond by increasing blood flow to the area, which can cause the surrounding tissue to swell. Mucus can then thicken and get stuck behind the swollen nasal passage and you end up with a stuffed up nose.
Mucus, by itself, is a very good protective mechanism - it is only when it gets over produced that it causes problems and steps can and should be taken to reduce it a little bit. First of all, you can blow your nose more frequently as that can help keep it free of mucus. You can also increase the humidity of the air you breathe, especially when you sleep, with a vaporizer or humidifier. This helps keep your mucus liquefied and less likely to get stuffed up. You can try to avoid irritants such as tobacco smoke and sudden changes in temperature, as they can make your nose drip more, too. Finally, if you are suffering from a cold then there are some medicines you can take, like decongestants (for stuffed up noses) or antihistamines (for especially runny noses) to help make you feel better.
Even though it might seem annoying, mucus is a good protective system to have in place. It is much better to have germs get caught in your nose than in your lungs.