While technically the board of directors sets executive compensation, one must remember that those board members are largely executives at other companies and the executives are often board members elsewhere. So in practice it’s a circlejerk and executives do set their own compensation via implicit quid pro quo.
Also, you appear to be confusing morality with legality. Screwing over line employees up to and including looting the pension funds to pay executive bonuses is legal (see Hostess bankruptcy for an example), but it’s also immoral.