There are many reasons for this. One is that yes, it is in their contract. If I'm making a million a year somewhere and you ask me to give that up and come and work for you, and then it doesn't work out and I can't get things accomplished with the team and resources provided, so I have to leave, then I will get X as compensation for wasting my time and taking me away from a job I could have been great at. (You may not see a difference between sleeping on the job and not being able to accomplish a goal that required a lot of other moving parts to be in place to accomplish it; people who write these contracts do.) Without a contract like that, it's hard to get people to give up their million dollar a year jobs to come and take over at companies that need them.
Another is that people who make a LOT of money can easily afford to pay lawyers to help them sue for wrongful dismissal. And since "didn't meet goals" is rarely as cut-and-dried as "sleeping on the job", they may win those suits some times. And even if they don't, it costs a lot of money to defend against them. Some you might get back, like lawyers fees, but others you don't, like the time people take keeping notes in case there's a lawsuit, etc. Giving someone a severance payment in exchange for not suing can be cheaper overall.
There are others: these two probably cover the majority of cases.