We also pay people based on how much power they have. People with lots of power and influence have more pull to ensure better pay for themselves. That power may come from being hard to replace, but it can also come from other things. Even bad CEOs that run their company into the ground, who really should get replaced, still draw significant pay on the way down, and may only be hard to replace because of the power they hold over the company.
But also: people don't get paid based on the value they create for society, but on the value they create for shareholders. So running a company into the ground may actually be short-term profitable for the shareholders if you manage to keep dividend payouts high. Parasitic companies extract value from society and give it to their shareholders. Lots of companies do enormous damage to various aspects of society, but as long as they don't have to pay for that damage, they can still be profitable for their shareholders.
Shareholder value is the biggest curse ever unleashed on/by capitalism.