It is something every writer hears. The mantra, ‘write what you know’.
Is it a good mantra? Yes and no. Why do I think it’s both good and bad?
I regard it as both good and bad because for some of us, we have no interest in writing what we know, and for a couple of genres, it is nearly impossible to ‘write what you know’.
Which genres, you ask? Science Fiction and Fantasy, (no matter what the book stores tell you, they are TWO separate genres.)
Westerns, you can technically learn. Romance, everyone has a little of that in them. Horror can come from nightmares. Popular literature, comes from daily life. Historical, do excellent research.
Science Fiction, however, is usually set in the future. And unless you’ve got a time machine and you’re holding out on the rest of the world, you can’t research the future.
Fantasy is generally set in world where magic, dragons, elves, mermaids and other mythical creatures are commonplace. Again, this is essentially impossible to research as we don’t have those things in this world. (I will digress that maybe we have elves. Yes, ask me why. Yes, I will answer.)
So truthfully, I’m not a big follower of the “write what you know” mantra. But again, it is what you feel is the best decision for you as to whether or not you follow the mantra.