Many people used to be racist. Why do you think they changed? (Hint: it wasn't because they were ostracised.
Do you mean many people around today were formerly racist, or that racism used to be more prevalent in previous generations?
Either way, it's probably not that important a point. Within living memory, racism used to be built into many countries' laws and institutions. It wasn't until 1967 that laws against interracial marriage were removed in every American state; apartheid in South Africa didn't end until 1994. If the framework you live in is racist, then it's not surprising that racism was accepted as the default, self-evident position.
It took more than polite debate to repeal those laws. (Even participating in a debate is a privilege. How can you reason with someone who believes you're subhuman? Nothing you say has any value, and that's if you're allowed to open your mouth in the first place.)
But the point is that many of these laws and frameworks don't exist any more, at least in the UK and US. We all have access to a near-infinite range of information. It's a choice to be racist, not the default.
Apart from naive and sanctimonious, the idea that extending friendship with outright, steadfast racists might somehow have a good influence on them is very patronising. You think that they'll discover the error of their ways, purely because you're prepared to talk it through with them? Is it an equal discourse? Do you think, if they're reasonable and convincing enough, you might come around to their racism? No, that would (hopefully) never happen. But then maybe you shouldn't assume that their views are pliable enough to change when someone with better judgement comes along and deigns to 'engage' with them.