N-Body, multivariate optimization, expert systems, and *especially* genetic algorithms!
Could be a fantastic discussion, but anything this generically ambitious is likely to take a *lot* of computing power. You're also probably going to want to do in script (slower again) to meet licensing requirements. Even if you generate with very simplistic randomness, it takes enough time to fully calculate creatures after you've decided on the random factors. Users typically want an answer within a couple of seconds per randomly generated NPC/monster. Sure, you'd allow for greater time as a DM preparing the "boss monsters" for an adventure, but you'd hopefully have specific, non-random ideas for those in any case.
I'd return to the classic engineering use case scenario, and see what the deal breakers are (Einsteinian thought experiments).
Take the Druid as an example. It's a known case, but lets see how we go with a D20 scenario, rather than a D&D one. Let's start with core D&D, except there is no druid which has a big problem with metal. Pretend you are going to have a system that, if you create an unexpected druid class with a metal problem, will still do sensible things.
What's sensible? Well, no weapons or weapon proficiencies that involve metals. What about heavy armor proficiency? Wouldn't make sense if there is no heavy armor that doesn't contain metal (is there? quick now! - anyone except Charles Greathouse

). How does a generic system allow you to specify this metal issue in the first place, in such a way that it will affect subsequent random generation?
Approaching from the other end:
Try something as simple as race and alignment. Can the specific campaign have an affect? If we're in MiddleEarth, we'd expect some pretty different results generating race and alignment when comparing Hobbiton to Mordor (there's always a chance you'll find a couple of LG halflings near Mt Doom, though). Apart from the fact that race descriptions give the most basic alignment variation descriptions, you may even have different alignment spreads for the same race, based on *where* they're found.
I mention these just because initial suggestions seem to point to some kind of utopic answer. I'd really suggest that serious thinking be put into considering the boundaries of the problem, before possible ways that it may be solved. I don't, for example, that the Druid metal problem would be generically solved in scripted code, in anything like the time it takes for a typical gaming session.
How about assigning skills? There's a bucket of issues there, like:
- No database I'm aware of specifically states whether or not a race has legs. How do you know that a race can "Jump".
- What does "Bluff" mean to a race that doesn't communicate (speach or telepathy)?
- What does "Innuendo" mean to a Gelatinous Cube?
- What does "Swim" mean to a dire bat?
What about items geenration, and the possibility of magic?
- Some play high magic, average, low magic, or even no magic (D20 modern?). All this points to being able to specify different tables for different campaign settings (and possibly different locations within the same world map...).
I''m afriad that any practical random generation solution is likely to lead to all sorts "ridiculous" results every now and again. From what I know of trying to sensibly codify things, a huge amount of effoty that takes a huge amount of time is likely to improve things only slightly.
Another side is that a good solution is likely to consider an encapsulating environment beyond "I want a random NPC/creature", such as identifying a campaign location that points to certain alignment, race and class spreads.
It points to a greater campaign-specific approach, such as CS, or my own RPM.
I asked this board about this very question a couple of months ago, and nobody could come up with anything really feasible.
At the moment, in my own RPM program, I have a little known and very under-utilized "Table Generator" feature. It allows you to build your own tables of items, classes, races, alignments, spells etc. At the moment I've only entered in a couple of the DMG wandering monster tables that actually generates an encounter for random races.
Based on questionnaire feedback for RPM, people *really* do want random race/item expansions, so I'll be into expanding that. It'll probably go as far as basic tables for specific adventure or campaign location random tables, classes and alignments - but nothing *too* smart.
I really think it comes down to setting yourself practical boundaries that you can live with...