Three men are talking: A programmer, a doctor, and a lawyer. The lawyer says, "Man, the only way is to have a mistress. With all these divorce suits, it's terrible. The only way is to have a mistress." The doctor says, "Are you kidding? With all the STDs out there, you want a wife and that's it." The programmer says, "You need both a wife and a mistress. Because when you're not with the mistress, she'll assume you're with your wife, and when you're not with your wife, she'll assume you're with your mistress, and THAT leaves you more time to be in the lab programming!"
(Found on http://stackoverflow.com/questions/234075)
It was possibly immoral, if you think there's a moral requirement to hire the first person that fits the role. Though, employment is a relationship, and like any relationship there can be a host of reasons why they don't start or work out. It can simply be a matter of preference, on both sides.
It's not illegal to discriminate, it's illegal to discriminate for particular classes.
The higher pay let's you save more for retirement, let's you afford a better school for your kids, a home in a nicer neighborhood, etc. There are trade offs.
As a side note: I'm over 40 now, but I do recall being 27 and interviewing someone in their early 40s who was qualified and enthusiastic. I passed on them in part because I felt guilty hiring them; to work on my team the person would have to move their family to a new city, and I didn't want the karma of bringing that many people into a world where the team/project I was on was staffed and led by 20-somethings -- and therefore chaotic and unlikely to survive long in any particular form.