Figure out some cosmology and stuff like how magic impacts everyday life. It's 3rd Edition D&D. Healing spells and resurrection are fairly common, and in the setting as written, heroes are quite wealthy while commoners are...not. The basic setting has a ridiculously broken economy, and it's also pretty interesting to think of what magic like healing and resurrection would do to civilian life.
(Sorry your mom died. But we just can't afford the expensive diamond the clerics would need to bring her back. So I guess it's just you and me now, son. Or I could sell myself into service to this wizard to pay for it... I'm sure he's legit...)
Yeah, the setting is REALLY full of Unfortunate Implications. Especially when you consider that a moderately wealthy character could go around raising orphans' parents from the dead. And they don't, those bastards. But then, people aren't really afraid to die either, because they know for sure that the afterlife exists and some of them have seen it. Makes evil characters kind of scarier because they know just how horrible of a place they'll go...they have to be deluded. Or maybe those orcish barbarians go to an entire OTHER set of afterlives, that are absolutely real and relevant to them. Think about it...or actively choose to make it not a part of your campaign. Just don't let the moral issues sneak up on you unprepared!
And yeah magic really helps the megacities work at all, since if magic is prevalent, there's very little disease and plenty of food.
The DMG has some tables on how many people of what classes and levels you should expect in a city of X size. It absolutely won't apply to your megacity, but maybe you could apply it to a ward or a neighborhood or a city block or...well, maybe you'd just better figure out for yourself how many level 20 wizards there are romping around, and just how many clerics there are, and what they do for a living. And yeah, remember that in 3rd Ed., an awful lot of commoners are above level 1.