I'm primarily a business writer who focuses on topics related to human resources and human development. I probably write best about these areas, but also take on assignments from other areas, including finance and technology. When I write about cloud computing, for example, I approach it as an opportunity to learn. I'll spend much more time conducting research than writing. But by continuing to grow my knowledge, I expand the areas I can write about. This also means I have more potential work, which is good financially.
Of course, if you feel completely lost in an area -- say you're asked to write about particle physics and you've never studied physics at all -- then your best bet is turning down the offered assignment. When you write, you must do so with "authority," which means you are confident in what you are saying. If you can't write with authority, you're better off not writing at all. Readers always know when you're faking it, so don't even try.
I suppose this doesn't answer the question of whether you should "write what you know" or not. I would suggest that you write what you know or what you can learn without too much trouble. Again, the key issue is having enough authority in an area to give value to the reader. Specialization is really good for deepening your knowledge and increasing your authority, but it limits your ability to learn new things and make enough money to pay your bills. I wish I could be idealistic and ask you not to consider money at all, but writers need to make money just like any other professional.
The good news is that it's now easier than ever to learn new things. More and more, knowledge is everywhere -- in libraries and especially online. You can find tons of information on any topic, a boon to all writers. To broaden "what you know," you need to become adept at research. This is something you should have learned long ago at school, but all it takes is having a computer, a working brain, some determination, curiosity, and enough time to read and reflect upon your research. I learn constantly as a writer (one of the joys of the job), and share what I've learned for the benefit of my readers. When I feel comfortable learning about something, I know I can write about it too.
So, yes, "write what you know" is great advice, but consider carefully how much of a specialist you want to be. By having the ability to learn more, you can broaden your mind and your list of writing clients.
What's your view on "writing what you know"? Feel free to comment on this classic advice via the comment box below.