Well I only know math and theoretical computer science (algorithms, AI, complexity theory, etc), but since you specifically bring up math...
Doing good academic research is HARD. The vast majority of current researchers are putting out random crap that will never go anywhere useful because frankly they are not good enough to make real progress. Your 99% of people who couldn't even get jobs in academia would be in even worse shape than those guys. It's good they went into something else where they might actually contribute something of value.
As for the job sucking, it's actually amazing... if you're one of the few people who's brilliant enough to make a difference. At that level, you'll get tenure no matter how hard you work, and then you have it easy. Six figure salaries are standard at reasonable research universities, and top universities routinely give out 250k+ in addition to the option of consulting on the side and all the other benefits of tenure with almost unlimited freedom.
Sorry if this sounds harsh. But academia is one field that does not benefit from having more mediocre people doing make-work. And if you're even concerned about whether tenure will be a problem for you at a good university (such that you're working 60+ hours a week to make it happen for example), you ARE going to be mediocre. Math and CS research are progressing as fast or faster than they ever have before. The system is fine, and the majority of great mathematicians / computer scientists are still doing research.