As with pretty much everything else, your narrative viewpoint will determine your approach here. If you have a chatty, first-person narrator, you can get away with some explanation of the situation and world if you make it interesting. If you have an omniscient narrator, you have the freedom to step outside the characters and provide some set up. It's easy for writers to abuse this freedom, though. I find novels that open with long explanations, descriptions of scenery, of social institutions, or historical set up to be off putting, as a rule. I don't know if everyone feels as I do, however. I still run across books where writers do this.
My advice is, if taking this approach, not to go on for pages and pages, and to utilize a lively and engaging voice that keeps readers entertained.
Personally, I find limited third most challenging in this respect. You're bound by the same "rule" as in first--nothing the viewpoint character in a given scene isn't aware of and thinking of at the time. But you don't have that first-person perspective to step outside the current story and talk directly to the reader without it sounding omniscient.
I prefer when the story starts with a character doing something, and information is provided when it becomes relevant. A fellow writer once described it to "dribbling" intriguing bits of world building in as needed. With SF and F, there's a tendency for people to default assume certain things about a world, based on the cues you provide. My nemesis, since I like pre-industrial settings, is for readers to assume we're in the bog-standard "faux medieval" kind of world, so they can rebel when elements that aren't (in popular perception) medieval are "dribbled" in.
It's especially tough if one is trying to create a culture and society that isn't based on a given real-world one but just so happens to be at a particular technology level and exist in a particular kind of biome people associate with a given (often stereotypical) culture. This is probably why so many writers default to appropriating superficial cultural elements to give their fantasy societies generic "Asian" or "Middle Eastern" or "African" or "European" feel etc., something that is becoming increasingly problematic if proper attention to the deeper elements of a culture (and not just surface trappings) aren't thoughtfully incorporated.
This is actually an issue that's shut down my writing efforts recently. How to gradually dribble information in that creates a rich and immersive setting that informs the story and characters (so they don't just feel like modern westerners playing dress up) without readers going, "Huh?" when I dribble in something about a god or cultural institution or whatever that either contrasts with assumptions they have already made, or leaves them wanting more information about how things work NOW.
I see lots of writers doing it in various ways, but since most who aren't using standard issue "fairy tale" versions of Medieval Europe (inaccurate, but at least in line with what most fantasy readers expect) are using world building models that are based on a particular "real" time and place (sometimes kind of clumsily, sometimes with more skill), it's hard to get a sense of how to do what I want to do.