I had an English teacher in high school who took this ‘rule’ a little too literally. As a burgeoning science fiction writer I was often met with this comment in red across the bottom of my creative writing assignments; write what you know. Having read so many novels set in other times and places where no humans had yet gone, I knew she was wrong.
The thing is this rule is actually a set-in-stone-not-to-be-broken rule when you understand it properly. Perhaps it would be better phrased as if you write something that others know, make sure you know it too.
As a writer I can put a cattle station on planet Rurak with no problems. I set the rules about Rurak, so what I say goes. However, if I name a real breed of beef cow as a milking cow, then I’ve failed my reader. The facts that exist should be known by the writer. If I can’t be bothered researching cows, then I need put a different animal on Rurak or make one up.
Just as an aside, I think it is always better to do the research on the facts. Besides giving your story verisimilitude, many readers (me included) bristle at the idea of an animal that looks like a cow, moos like a cow and gets milked like a cow, being called a Beekramp for the ease of the story. To me that feels like sloppy world building and a writer who didn’t want to research cows.
So yes, write what you know, but feel free to take what you know and put it in a fantastical world of your own creation. Just be sure to know that world you invent. The last thing you want is someone reading your story and picking up on the parts where you have broken your own world-building rules! But that’s a whole other post…