Ageism is one of those made up -isms. When someone discriminates on the basis of race or sex, it is frequently irrational. Unless you’re hiring for a sunscreen commercial, race just doesn’t tell you much about how good someone is for the job.
Age, on the other hand, tells you a lot. A person who is 65 now was 55 when Facebook was started. They were 45 when cell phones hit the market. In a lot of roles, that matters. Moreover, someone who is 65 is eligible for retirement, they’re more likely to die, they’re unlikely to take direction as well from a boss who is likely to be younger than them. These are all true by definition or very highly correlated with age. Age has predictive power about work-related attributes.
I many industries, the additional experience is as much a liability as an asset. If an industry is trying to innovate, to overhaul processes to use new technologies to gain efficiency, someone with years of experience in an analogue workplace may find that change more challenging than someone who is used to doing everything online.
That isn’t always true: since enterprise applications tend not to be as glitzy as Facebook/Google/Twitter, older workers actually tolerate them better than digital natives whose expectations are never met. It can’t be said that age is all costs, and surely there are some roles where age is at least as much or more an asset than it is a liability.
Still, in a lot of cases, the benefits don’t outweigh the rationally predicted costs. In a lot of cases (not all cases, of course, but most, and in any case in a larger percentage of cases than is the case with sexism or racism), ageism isn’t irrational, it is actually pricing in real factors about a potential job candidate.