You're spot on. PHP is really bad, but zillions of hours have gone into tools around and on top of the language such that it's actually not that bad to develop in anymore.
Why was all this time spent on PHP instead of doing anything else? I don't have a clue.