As you are no doubt aware, the immune system has many ways in which it causes problems for us humans, rather than the bacteria, viruses etc. it should be focusing on.
We call this 'auto-immune' disease. Depending on the area affected, auto-immune disorders get different names (for example, rheumatoid disease affecting joints, psoriasis affecting skin, and so on) but it is all the same basic issue.
Traditionally, when it comes to the mind and psychological or psychiatric disorders, the assumption has always been that the disorder is localised in the brain itself, with or without 'stress' or adverse life experiences as a cause or trigger.
The idea that the immune system could attack or interfere with the brain enough to cause depression, or psychosis (for example) has not really been recognized except in the last 5 years or so.
Listen to this excellent podcast from the BBC for some more information.