As you accurately perceive, there is wiggle room in the law. You can in fact discriminate against candidates based on their political leanings, their taste in music, and their hairstyle. Those things do not define protected classes under the law. But you should not do that, for the same underlying moral reason underpinning the fact that you can not do that because of someone's religion, gender, or race, no matter how ineffective or unproductive working with someone of a different race might make you.
Sensitive/controversial/potentially-just-plain-wrong opinion incoming:
I completely agree with this. But, as a black male, I don't want someone who's racist to be forced to work with me. Extreme out-of-the-park example; I don't want the KKK to be forced to hire me because of affirmative-action or something. That'd be awkward for all of us! I'd prefer to get at the root of the problem and change society's views such that nobody needs to be forced to hire me and they do it because they like me and think I'll be good at the job; and being black doesn't bother them. If someone doesn't hire me because I'm black, I suspect it's better for me than being hired anyway and having all kinds of odd social cues happening in the office because someone(s) is trying really hard to hide their racism but it slips out every now 'n again.
Maybe there's a catch-22 in my reasoning. To solve racism, people need to be exposed to more people different from themselves but I don't want to be exposed to racist people until they're not racist anymore.
Yeah, but I have no trouble in advocating what I believe is right, whether or not society agrees☺
I tend to think that our current society places too much faith in diversity qua diversity, and cares insufficiently about similarity. I really do need to get around to reading Bowling Alone…
Well, it certainly leads to discriminating against people who don't fit into the team culturally. But really, is that unfair? Isn't the goal of a software team to produce great software, not to be a force for fairness or justice or anything else?
If people with much in common work better together than do people with little in common (which I believe is likely to be true), and if the team works together, then isn't it better to hire people with much in common?