How do you write a character with a belief system fundamentally different from your own without tainting your narrative with a personal or cultural bias? This is something that seems impossible. Surely some of your own personality, your own cultural bias must be impressed on your writing, no matter how well researched. I'm only willing to accept this with this caveat:
The only ultimate bias is the one formed by the language in which you are writing.
There are limits to what English can and cannot express with simplicity and ease. The same holds true for any other language. French provides a bias with the very word "the" since nouns are gendered. In English, the biases are simply more oblique, and I'm not going to list them not just because it's too deep a conversation but because I can't possibly know them all -- I'm not sure it's possible to.
All that is moot though -- my point is that writing a character with a different fundamental viewpoint should be no different than writing a character that shares your views. Neither of them are you -- they're both strangers in a way. One may have more in common with you, true, but social values should be treated no more differently than personality traits, or even physical traits. You're can't build all your characters exclusively on yourself, no matter how interesting you think you are, and writing a character who is racist or homophobic or atheist or fundamentalist or whatever shouldn't be any different than writing a chracter who is tall, or short, or fat, or thin or angry or passive or brave or cowardly.
I mean, most of us have already written and played racist characters, we just haven't noticed it -- who played D&D? Who reads Forgotten Realms novels? Fantasy is fantastically racist. Dwarves hate Elves, Elves hate Dwarves, Everybody hates Orcs, White People - er I mean Humans have a diverse culture with all sorts of interesting things, and they hate Elves, Dwarves, Orcs, Goblins, Gnomes, Halflings, Half-Orcs, whatever. The sort of jocular racism that exists in D&D is still racism, just with a candy coating. That doesn't mean it's bad -- the past was racists as hell, and classical fantasy is the past.
Don't feel bad about any of that, how the hell were you supposed to know? But realize that when you've written a character or played a character who believes in Black and White good and evil, you have probably written someone who has racist views. And I think probably all of us, regardless of any other viewpoint, are not racist, nor do we (for whatever reason) wish to be. But at the same time, everyone is, since no one is telepathic. We can't be fully empathetic with someone because you aren't that person. Why do you think twins always seem so close? They don't share a special link, they just are the same biological person. They react the same (or at least more often than two otherwise related human beings), at a fundamental level.
This means that you're always faking it when you're putting yourself in someone else's shoes. You're imagining it, but you can't imagine what you don't know. That's why it's important to read widely; gain experience and a wider breadth of cultural viewpoints. You'll find that writing those characters who seemed strange or reprehensible will become much easier. Travel, too, don't just read. That's just one person (sometimes more) funneling their experiences through fiction, which is great too, but if you're a writer, you need more than just condensed milk. You need the whole cow.