Write what you know.
Nearly every author has heard that old adage at one time or another. And many authors go off to write stories featuring people like them. That's all right. There's nothing wrong with it. However, some authors take the saying deeper, going into their hearts and souls to pour a little of themselves into the book. It doesn't matter if we're writing sweet tales of small town families or highly charged science fiction adventures. If authors put a little bit of themselves, or a whole lot of themselves, into the story, it will resonate with readers.
I don't think this means that we can only write about people like us. If we did, then there'd probably be no books about vampires or werewolves or aliens on a spaceship. But it does mean that we have to be open to the world around us and see our own qualities reflected in others. The main character may be from a different planet or a different time, but that character probably has much the same thoughts and feelings as we do. The same hopes and fears most likely resonate in a historical person's life just the same as they do our own. (Of course, there will be exceptions to this, such as in science fiction where well-written aliens won't think or act like we would.)
In addition to the emotional and mental ways you can put yourself into the story, you can also draw on experiences in your own life. If you write inspirational books, then your own faith and spirituality may be put into the story to varying degrees, for example.
But this doesn't mean you can't research and you can't put things you don't know into books. If it's a subject in which you're interested, then that's a part of you. The important thing is to make sure you are invested in some way in the story. Then, you'll be sharing more than just a made up story with your readers; you'll be sharing a part of yourself.