Young people may be measurably quicker thinking and willing to work longer hours for less pay, but that doesn't help when they lack the skills and experience and end up making the
wrong decisions.
Older people generally aren't willing to work for the same low pay because we have enough experience to justify it.
This kind of discrimination is peculiar because the exact same people are often sought after if you only change their title. E.g. as a consultant I'm sought after at a far higher price point, and my age and experience are a big selling point, where trying to apply as a regular developer would make people wonder what's wrong.
This is more of a perception and marketing issue than it is about young people having an edge, and the pereception comes down to the same reason we ascribe more value to e.g. an expensive watch than a cheap one: Signalling effect.
Being a developer at 40 signals to a lot of people that someone doesn't have the skills to get promoted, because they don't understand that you can be a developer and do stuff any random CS graduate could do, or do stuff that makes you one in a million without getting fancy titles.
Conversely, being a consultant signals to people that I must be able to do stuff other people can't.
You see the signalling effect clearly when pitching for work as a consultant: I have conversations with people that are 90% about me telling them whether or not I can do the work, rather than being interviewed by someone who is trying to figure out if I can do the work. The assumption is that my judgement can be trusted because I'm a consultant rather than some "lowly developer" applying for a job.
Seeing the difference in respect and attitudes (and money...) makes me even more determined not to go back to normal employment.
(There's also a subtle difference there between attitudes to presenting yourself as a "consultant" vs. "contractor")