he wouldn't have been able to have sex with a white prostitute either. Eastwood cast a black actor because the actor that he liked was black. Pretty much every western is full of historical inaccuracies, and you can care about any given inaccuracy or you can let it go. The racial tolerance is hugely improbable but the anachronistic clothes and guns are impossible (apparently, I didn't notice that on my own).
It was only in the early 90s that you really started to see alot of movies that cast black people in racially neutral roles, so I can appreciate that they just wanted to cast the best actor and play the script that they had.