OK, this ran away from me and I spent the last hour or two working out some ideas. What can I say? Its a fascinating subject
As I see it, in order to ascertain the exact population of leveled characters (LCs) and their levels, there are several variables: World population, prevalance of leveled characters, and distribution of characters at different levels or tiers.
World Population of D&D Campaign Worlds
The world population in 1500 AD is estimated to have been about 450 million. That's the high Renaissance - which seems to be about the level of most D&D kitchen sink campaign worlds, or at least like the Renaissance, portions of D&D worlds have that level of technological and society development. But different campaign worlds would have different population levels. Looking at Earth again, we could consider different eras and their respective populations:
Early Industrial (1800 AD): 1 billion
Renaissance (1500 AD): 450 million
Early Middle Ages (1000 AD): 250 million
Late Antiquity (500 BC): 100 million
Early Antiquity (2500 BC): 20 million
Late Neolithic (5000 BC): 5 million
So the first thing one would have to do is decide which best suits their world's basic societal era. I would think that the Forgotten Realms would be closer to Early Industrial population level, considering the existence of multiple races, the Underdark, and greater population density than Earth (i.e. there are few vast areas with little population, unless vast regions of Earth during the Renaissance).
A points-of-light or low fantasy, Sword & Sorcery style world might have 20 million or less. It really depends upon the world.
Prevalence of Leveled Characters
This is the central question question of the original post, but my contention is that it needs to be addressed alongside the other two factors. One question that should be asked is: are only PCs leveled, or are NPCs also leveled? If the former, question over: the only leveled characters are the PCs. If the latter, the question becomes more complex (and interesting, imo). But even if taking the latter approach, we must remember that a level implies a degree of training. A farmer who serves in the militia during the occasional orc attack is not a fighter, but a warrior. Class = training. This doesn't mean that training has to be rare, but it is significant.
I see it as a scale, with no "right" number, but just benchmarks to consider:
Very Common (1-in-10 or more): A lot of folks pick up levels, whether because the world is dangerous and training is common, or because it is just that kind of world. Or imagine it this way: if you interact with a dozen people in a day, one or two of them are leveled.
Common (1-in-100): Leveled characters are plentiful, with most villages have one or even a few, a handful in every town, dozens in small cities, hundreds in larger cities.
Occasional (1-in-500): They do exist, but not in every village. There are a few in every town and maybe a dozen or two in small cities, a few dozen to over a hundred in large cities, and quite a few adventuring parties scouring the land.
Uncommon (1-in-2000): This seems to be the tipping point for when they become more rare. There may or may not be one in a town, a handful in a small city, maybe a couple dozen in larger cities. Adventuring parties are rare and noteworthy.
Rare (1-in-5000): They exist, but are few and far between. You generally won't meet one except in small cities, except for the stray adventuring party or luminary.
Very Rare (1-in-20000 or fewer): The PCs and other adventuring parties and a few luminaries, but that's it.
I would imagine that the typical D&D world would be somewhere in the "occasional" to "uncommon" range, but it really depends upon what you're going for.
Distribution by Level/Tiers of Play
Level 1-4 characters have been described as apprentice adventurers or "Local Heroes," Tier 2 (levels 5-10) as true heroes or "Heroes of the Realm," Tier 3 (levels 11-16) as paragons or "Masters of the Realm" and levels 17-20 as superheroic, legendary, or "Masters of the World." Or we could say, low, heroic, paragon, and epic tiers.
Now the distribution of leveled characters can vary, depending upon how you want to approach the matter. I see two big factors to consider: death and stasis. How many characters survive a level? Not just PCs, which is inordinately high, but all leveled characters and adventurers? How many gain a level through some experience, but don't advance do to their primary career being something else? And how many adventurers hang up their swords and staves and retire or choose a safer profession?
These are all highly variable and subjective. But a simple way to address this question would be to ask: For every one "legendary" character (level 17-20), how many paragons, heroes, and apprentice adventurers are there? Is it 1 to 10 to 100 to 1000? Or is it more like 1 to 100 to 10,000 to one million?
I would posit three ranges:
Soft (x10): 1 to 10 to 100 to 1000
Moderate (x50): 1 to 50 to 2500 to 125,000
Hard (x100): 1 to 100 to 10,000 to 1,000,000
One, albeit formulaic, approach is to imagine that the amount of leveled characters that ever make it to the next level is half. Meaning, of a 100 1st level characters, 50 make it to 2nd, 25 to 3rd, maybe a dozen to 4th, six to 5th, three to 6th, or two to 7th, and one or none to 8th or higher. If we extrapolate from one 20th level character for every level, and then add up the tier totals, we get the following:
For every 1 20th level character, there are 15 total level 17-20 characters, 1008 level 11-16 characters, 64512 level 5-10 characters, and 983040 level 1-4 characters. Or to put it another way, only about one in every 65,000 1st level characters make it to 20th level. That doesn't seem that far-fetched, if you think about it.
But you could also imagine a "softer" progression. Maybe a greater percentage make it to higher levels.
Example A: High Medieval/Renaissance with Occasional Prevalence and Moderate Distribution
Let's imagine a fairly typical kitchen sink fantasy world, with a Renaissance level population, say, 500 million people, of which 1-in-500 people are leveled, or about one million people., and moderate distribution. In this world there are seven or eight Tier 4 characters, a few hundred Tier 3 characters, maybe about 20,000 Tier 2 characters, and the rest of the million--almost 980,000--are Tier 1.
Example B: Dark Fantasy/Sword & Sorcery with Common Prevalence and Hard Distribution
Now let's imagine something more archaic: a world akin to early antiquity, with the rare nation, a bunch of city-states, and most of the world being monster-infested wilderness with the occasional neolithic settlement, about 10,000,000 people, of which 1-in-100 are leveled characters, or 10,000 total. Of those there probably isn't a Tier 4 character, maybe one Tier 3, a hundred Tier 2, and the rest are Tier 1.
Etc.
Summary
There is no right answer, but I think if one addresses all three variables--world population, prevalence of leveled characters, and distribution of characters by levels or tiers--you can slide in some numbers and play with it to find an outcome.
Addendum
There are other factors to consider, but I tried to keep this
relatively simple. For instance, the above three factors could be modified in different regions with different levels of societal development, cultures, etc. I see this as an overall picture, and you can vary it per region. I'm sure there are other factors to consider...