In the most simple terms, the immune system is your body's protection against being invaded by small creatures that would like to make you their home.
The truth is that it isn't all that simple, and in fact many bacteria, viruses and other microbes not only live in and on us, but they are very important to our health and well-being. There are trillions of these microbes in the body, mostly living in the parts that are exposed to the outside, like the gut, lungs, and skin. The good ones help us digest food and in their own way help the immune system to keep us protected from bad microbes.
So the immune system actually chooses between leaving alone what seems to be harmless and violently attacking what might be very bad for you every second of every day. When it gets activated, the immune system has many specialized tools to fight the different kinds of invaders it meets. Some of these tools can be quite dangerous to our own bodies if they are not tightly controlled, and there are many additional ways in which the system regulates itself.
For the most part, the system is very good at what it does and we don't even notice how busy it is keeping us safe. However, sometimes things go wrong, and that's when we get sick.