When we breathe in, the inhaled air can contain dust, chemicals and other irritants that can be harmful to the body, particularly to organs in the respiratory system like the lungs. While the tiny hairs inside the nostrils (cilia) trap many of these particles, some will often get through. To help you out, your body reacts to try and forcibly expel the offending particles via the sneeze reflex arc.
There are a number of other reasons why we sneeze, including to clear the nasal passages when you have a cold, to expel allergens if you are allergic to something, and even bright sunlight can cause some people to sneeze.
When a stimuli is detected by the nerve endings in the nose, impulses are sent to the brain, which initiates a chain of physiological events that enable the body to rid itself of the unwelcome item.