The answer for my players has always been a good mystery. All my most successful lore deliveries have been because something was hinted at and framed as a mystery that the players could actively pursue and uncover. Not necessarily a straightforward "whodunnit", but stuff like "what happen to this ancient race that mysteriously disappeared after building all these bizarre structures" or "what does this colossal ancient device that responds to stimulus in unsettling ways do".
Instrumentality can help (how can we use this mysterious thing to out advantage), as can hints of a threat (what if we don't stop what ever this probably sinister thing is), but I've found that ultimately those seem to be secondary to just some compelling breadcrumbs and the right combination of information doled out and held back. I had a party change the direction of multiple sessions when an ESPing a random encounter seemed to reveal it to be part of an ancient piece of computing infrastructure.
People are often compelled by mysterious setting elements but sometimes in unexpected ways, there's surely quite a bit of art to it (c.f. Gene Wolfe, David Lynch) that I certainly don't think I have mastered in any meaningful way, so I usually leave many little bread crumb trails and drop unexplained descriptions in passing - many get ignored, but some (not always the ones I expect) become objects of continued fascination. I try to have a pretty good idea of what is going on behind the scenes with the mystery in question (I don't want to give the impression that I am just contriving things post hoc and changing things around based on what the players propose a la how I understand the show Lost to have worked, maybe it works for some but feels unsatisfying to me), but I also tend to leave room for improvisation and often need to do so (and I think players like a bit of this as well, like the meta level feeling that you've gone and poked at a thing the DM did not expect, kind of like when you find a gap of a map in a video game). Not every mystery needs to be solvable, many not without great effort.
That said, I think that rpgs are a bad medium for lore, especially for players.
All this to say that I think rpgs can be a great medium (maybe uniquely great) for lore delivered via partially solvable mysteries, partially because a good mystery is just naturally compelling to people, but also because it makes it interactive - players can zoom in on things they find particularly compelling, and use their actions and brains to uncover more. I think you just have to be comfortable with the possibility (probably the guarantee) that many things will not be revealed - which can be great, you should probably be just hiding many things in your setting for your own pleasure. The sense that there is a lot out hidden out there is nice for players, even if most of it is never made concrete. Luckily a lot of rpg settings (like the DnD implied setting) are great for a natural texture of mystery - generally pre-modern cultures, ruins of ancient more advanced civilizations, horrible sinister forces, etc.
I think another way to make lore matter to players is to give them a hand in creating it, either directly (players can create gods, regions, maybe there are multiple DMs in the same setting) or indirectly, by giving them control of factions or resources - political power, strongholds, armies, etc. - that are at the scale that their interests force them to contend with "lore" (the other factions, political systems etc. of the setting).
Lastly, I've always been compelled by the idea of making NPCs more memorable, more intractable, more useful to PCs by attaching "lore" - again not necessarily exhaustive ethnography, but distinctive bits of custom and (perhaps slightly alien) mindset. Along the lines of this
blog post, and this
other one on usable customs:
Get it in your head that the average inhabitant of your setting isn't some boring neutral. They are, generally, provincial, cunning, passionate, and concerned with the mores of the land. They are quick to try something and to join something. This makes a lot of incidental encounters more dramatic
I think there is a reason players love "speak with X (animals, plants, objects" magic (and I do to) - you get to explore a particular alien mindset that likely has information about the world that would otherwise be inaccessible.
In general, I think this all is very useful as a DM, because ultimately I'd prefer my players care about the world even more than any individual character (who may come and go - it's a dangerous game they play) - not in the sense of having an encyclopedic knowledge of the history of the setting, but caring about and engaging with the movers and shakers of the world and the marks they can leave upon it - they should be key actors in creating the new lore, the stories future setting inhabitants would tell, as the game proceeds. "Lore" is only a piece of this, even in a broadest interpretation of the term, I think you also need satisfying mechanics at various scales. But I aspire to the following description by Anthony Huso:
This game is not about a band of heroic characters. It is about an entire world that, through player choice and creativity can be interacted with to bring about stunning events and outcomes. Outcomes that you will not plan ahead of time, but discover through play.