If you force people to have someone in their house that they don't want, they are not going to rent their house out. This will lead to less units on the market. Your point about racism is fair, but I don't think the answer is a solution that reduces rentable units on the market.
Okay, sell it to someone who will live there then. You're not a saint for taking a unit someone wants to buy and forcing them to rent instead.
What alternative solution to housing-related racism would you suggest?