They are paid millions because once you win the birth lottery, and if you are tall and loud enough, failing upwards becomes the default that is very hard to beat, even if you try.
And it's really, really hard to learn from your mistakes unless someone calls you out on your shit, which almost never happens to these people.
If the CEO came in and was amazing, then she/he'd get paid the same amount.
I mean, it's the exact same with engineers. They get paid hundreds of thousands of dollars because they're "top talent", but experience and resume does not necessarily a good engineer make. You interview and make a guess, but it's not like the best engineers always get paid the most and the worst get paid the least. They all get paid roughly the same.
The only difference is that bad engineers generally don't get fired at the rate that bad CEOs do. But I guess that's because the scale of impact is a lot less, and they're not so easy to identify and blame.