How could Ursula K. LeGuin write about life on other planets? How did Jean Auel write about prehistoric times? How does a woman write about a man? How do novelists write about Australia if they’ve never been there?
Of course the writer must research as much as possible, but ultimately fiction comes from inside the writer. If you’ve been discriminated yourself in some fashion – and we all have been – then, if you are Caucasian, you can write about how a black person or a first nation person feels – granted, of course, that you do a lot of research.
Write about what you know and most of that is inside you.