If management is mediocre, workers need to be top notch to deliver great products.
The odds you'll land at a place that have both are vanishingly low. It also takes a lot of work, money and interest to turn a big ball of mud around and no one gets a prize for that, people get a prize for churning out features and bugfixes, so this is what you get, specially because most large scale rewrite projects are utter and complete failures.