Not sure if this has been covered off in the posts to date (too many to read while at work), but airlines offer such perks to employees because they are generally lousy places to work. The pay is lower than other industries, job security (for non-unionized staff especially) is dodgy and the working experience is often difficult. For example. airlines are almost never (except CO and Southwest) appear on the Forbes lists, like best companies to work for.
So as a way of trying to attract and retain, they offer free or nearly free travel to employees, which can include space-available upgrades. Very few people get rich working in this industry, especially at the airlines themselves. Upgrades and travel are key components of their HR strategy.