Perhaps you can only level up from experience gained in a dungeon. Perhaps ripping off Jason Cone's "The Dungeon as Mythic Underworld" and subsequent riffs on it. A dungeon is a numinous, nightmarish, weird place. Those who adventure there gain powers to slice through armor or shoot off fireballs because the extraordinary laws of this place empower them. (As a sideline, it would explain hit points. Which are sort of abstraction of "difficult-to-killness" not a measure of physical injury, in theory. Spending time in the underworld could do that.)
The thing is -- on top of making all the PCs
Then there's the question of how you jump from zero to first level. Hmm -- perhaps it's when you first walk into the dungeon. You level up to first. Or you die. A lot of people die. Which does change the tenor of becoming an adventurer. There's always the risk of death, but an arbitrary and uncontrolled chance is somewhat different than fighting an ogre. (On the other hand, it would explain a lot of parties. Your party is the people who survived about the same time as you did. Especially if changing dungeons is hard.)
Though it's far from the only way.
Levels perhaps can only be gained by people from rare and unusual random circumstances -- born beneath a shooting star, chime children born while the monastery bells are ringing, etc. -- and these people gain a single level from the circumstances. The problem with that is to produce adventurers in even the quantity your typical D&D world has, you would have to have a LOT of first-level characters from the circumstance who never adventured because they never wanted to.
Might not be random. Might happen only to those people under those circumstances who would then go adventure. The problem with that is that it's limiting the characters who can, and to an extent that would not only make for unhappy players in a game, but a writer with hands tied. Why do so many D&D characters have unhappy backstories? Because happy people don't go on adventures! Who's going to abandon hearth and home, and the girl next door who's all set to marry him, to go get killed by ogres? Some will -- Bill Maudlin discusses the soldiers who really liked war in Up Front. They had peacetime jobs like swamp hunter and mafia bodyguard, and they were, frankly, kinda nuts.
Perhaps those circumstances will level you up only if it's your FATE to go adventuring. That would allow more variation but bring in the hand of the author/DM too blatantly to be anything but an obvious and clumsy plot device. Also, it will be obvious, particularly with clerics and wizards, that you leveled up, which would cause reactions all about you -- they know it's your FATE!
Perhaps once you're hit with leveling up, you must go adventure, or you will face punishment. Works for a book -- that is, for some books, doesn't fit the plots of others -- but heavily constrains the backstory of players in a game. Especially since you obviously got some training. . . .
I read a hypothesis once that clerical healing didn't affect the normal people of the world because it wasn't meant for ordinary people but for getting warriors back into battle. That would logically work IF you designed the religion to meet that (and most D&D pantheons are laden with gods who would be delighted to cure ordinary people), but by the same token, the gods who think that battle is so important would do A LOT to ensure that enough people were fighting it. They would not be happy with a handful of adventurers.