The immune system also has several other important jobs. For example, your immune system can detect cancer in early stages and eliminate it in many cases. Your body is a multi-cellular organism made up of perhaps 100 trillion cells. The cells in your body are fairly complicated machines. Each one has a nucleus, energy production equipment, etc.
Bacteria are single-celled organisms that are much simpler.
For example, they have no nucleus. Bateria are completely independent organisms able to eat and reproduce - they are sort of like fish swimming in the ocean of your body. At that rate, one bacteria can become millions in just a few hours. A virus is a different breed altogether. A virus is not really alive.