We do seem to be hardwired to sort things and people into different groups. This is one of the roots of prejudice, as it is the core of the "us vs. them" mentality. Some suggest that we are even
hardwired to be prejudiced, to blame our problems on "them" (whichever "them" our brains decide is/are) the culprit). My personal opinion is that teaching (by parents, teachers, peers, the media and the community) has a much bigger role in this than any hardwiring.
Think about it. From birth we are exposed to thousands of messages from people and the media. Our parents tell us who to associate with and who to avoid, in the process instilling their prejudices to us. We may be taken to Church, where we may be told that gay people are abominations who deserve to die. Television floods us with images of black people who are thugs, so we may grow up thinking that this is how all black people are. Perhaps our father is virulently anti-semitic and longs for the day that all Jewish people would be deported from America.
As we grow older and move into young adulthood we may join groups that allow us to foster the biases that were impressed upon us in our youth. We join a strict fundamentalist Church and participate in rallies to denounce the sin of homosexuality. Or perhaps we become a member of Aryan Nation or the Skin Heads. Whatever we do, we cultivate the hatred we have, and even pass it on to others.
There is a strong element of fear here as well. It is bred into us, and carefully nurtured--first by the person who put it there, and later by ourselves. Fear is an exquisite breeder of hate, for people who fear for their safety, their livelihood, their family, their lives, will go to great lengths to protect it. They will donate time, money and effort to be sure. And in some cases they will even commit acts of great evil such as destroying property or attacking/killing people.
So is it a mental illness? It probably could qualify as a form of obsessive-compulsive disorder, one of the personality disorders. If the person is so engaged in their ideas and behaviors that they can't live a normal life they definitely need some form of intervention, and if they pose a danger to themselves or others they need to be taken off the streets.