That would be age discrimination, which is every bit as illegal as racial discrimination.
But if other younger people who are applying that are just as capable, are you not going to hire them? Would that be fair to them?
Not entirely. I could go apply for a job as a basketball player in the NBA and they would not hire me.
First of all I am too old, too short, and I can't jump very well. That would not be discrimination because they would be able to tell by looking at me that I would not be able to help the team of talented athletes perform. Just by looking at me. They do not have to give me a tryout and let me play a couple of games.
Likewise, an experienced person would be able go judge that an older person probably would not be able to complement a team of bright, young, college prep students who have bought into the culture of the company.
Let me give you an example. When I was in high school I worked as a dishwasher in a cafeteria type restaurant. Everything worked very smoothly until they hired an ex-con as a dishwasher. Our job was to wash dishes, mop floors and whatever else anyone asked us to do.
The ex-con soon started complaining about being disrespected and resorted to intimidating his supervisors.
An experienced owner would have realized that the ex-con would not be able to function in the environment and not have hired him in the first place. Even if he might have worked well someplace else.