1) Human bonding (mother-child, family, and extended, symbolic tribes) is mediated in the brain by oxytocin. It turns out oxytocin also boosts xenophobia. Someone who claims to hail patriotism without being racist is therefore full of shit. They are two sides of the same coin, enlarging one enlarges the other.
2) Stigmatizing people for belonging to a group strengthens their tribal attachment to said group [a]. By punishing or threatening to punish a group of people, you enhance their tribal bonds and, per 1) their xenophobia, the very thing you're trying to rein in.
It's not about being moral, it's about effectiveness.
The only way to dispel tribal identity is to dilute it in a larger, weaker one, by being open to their members.
---
a. Which is why laws against "the public display of religious signs" are counterproductive. Likewise, ostracizing people who vote for extreme, hateful politicians is counterproductive.