Dungeon and Game Masters fill a very crucial role in any game they're present in: incorporating player agency and portraying the world surrounding the party. There are a few games where this role is split among several people, and there are even role-playing games where there's no GM at all. For the most part, though, at least one person shoulders the responsibility of designing the game and containing most of the meta-data related to the campaign. As such, this puts that one person in a prime position to be a teacher. Through the externalities of storytelling, shared experiences, transferred knowledge and the parties preferences, this strategy really livens up the game.
Whenever you read a book, there is take-away value. Maybe you're like me and really enjoy your nonfiction. Then it's easy to understand the take-away – I read about physics to understand physics. You could be more like my wife who prefers fiction. Those narratives have a different type of externality. I've learned about maritime terms from C.S. Lewis in The Voyage of the Dawn Treader. Stephen King shared with me his insights about addiction in The Drawing of the Three. Aside from knowledge, most readers will find a character within a work to identify with and thus share in some of their experiences. Imagining being the riled hero in Shakespeare's Macbeth isn't as fulfilling as actually being the hero, but a part of us still gets to share in their experiences.
Role-playing games often come across as just one big storytelling session. With our dice and character sheets and comprehension of the rules, that's really what we're doing – creating a mutual story in which our representative characters take on the risks we wish them to. As many games as my friends and I have played, we still regale one another with expeditions of parties long retired to our binders. The point I aim to make here is that the game doesn't stop when we put away our dice. That experience is added to the rest of ours, albeit in an imagined circumstance instead of an actual one. Regardless, a great many things can thus be learned during play.
When I was preparing a game set in a setting several centuries ago, it was my desire to really flesh out and focus on the technological differences. Obviously no one had cell phones; I mean it was a goal of mine to involve the characters in the start of that world's advancement of the level of technology as much as I could. After many hours of research online, I pieced together a basic understanding of how blacksmithing used to work, all the way out to steel-forging. As the characters approached the blacksmith, he wasn't “at his anvil,” but instead “gathering coal like a madman and cursing the glowing embers for the fact that his sword-iron was cooling too fast.” The party expressed an interest and he went into the finer details of his craft. Thus I got to teach within the medium of a role-playing game.
Tying this to the level of abstraction your group needs is crucial. Even though my players weren't as enthused about the details involved in turning iron into steel, it was still a better role-playing encounter than some rude blacksmith telling them to mind their own business. If it had bored the party then I wouldn't have bothered with the research. Or, I would have found a topic that my friends were more interested in, and prepared the game with that in mind. Essentially, all I was doing was trading one form of preparation (rules) for another (research). A multitude of options are opened, because remember that when you're the GM then you have a say in what the party encounters. It's our game too.
Mainly it's important to think of your group's preferences. Some people just want to kill kobolds. Others like intrigue, exploration and interacting with NPCs. The former prefer tactical thinking and crushing things while the latter prefer to be more engaged. You can engage them with creativity, rules from the book and funny names, but you can also engage them with real-world knowledge that they could use in their lives. Make sure it's not a lecture, as it's still a game you're playing, but a little extra sharing here and there could do anything from give them something worth pondering to save their lives. Happy bequeathing!