This is a very good, simple question which unfortunately, has many answers.
One of the main responsibilities of the immune system is to help the body fight off infectious organisms such as viruses, bacteria and fungi.
When these invade the body, a type of white blood cell known as a T-lymphocyte spots it (just as a policeman might spot a burglar whilst on patrol) and raises the alarm.
This brings on other T-lymphocytes which go hunting for similar invaders in the area.
At the same time, other immune system cells are recruited to the scene of disturbance. These include B-lymphocytes which secrete chemicals with the ability to destroy invaders, as well as macrophages which eat up infective organisms.
At another level, the process described above also operates to make sure that our body is free from cancer cells.
We have billions of cells in our organs and most of these organs will produce millions of new cells a day. Some of these cells will have ‘faults’, being cancerous or the potential to become cancerous.
As you know, certain lifestyle habits make this more likely to happen and we know that smoking increases the likelihood of lung cancer, for instance.
The immune system is able to spot these ‘faulty cells’ and destroy them. If this quality control system fails, a faulty cell will slip through the process, multiply and form a cancer.
More information can be found on my immune system page.