I don't see how this could be legal, even in an employer-friendly a nation as the U.S.
Sure, there are some outlier candidates who enter the field later in life as a second career. But for the overwhelming majority of candidates, "years of experience" is a very thin proxy for "age". I can understand requiring a minimum YOE, but there's no reasonable justification for a maximum.
Just because someone with many years of experience levels lower than typical doesn’t make them a bad person or even a bad hire. But it does make them a more risky candidate to hire (more likely to be "middle of the pack"; less likely to be "undiscovered superstar"), and so some companies choose to pass.
(I’m arguing that this is rational, not that it’s right, fair, or morally sound.)
If you don't have that endless stream, you are more likely choosing between "this candidate" against "no candidate" vs "this candidate" against "the next qualified candidate".
Failing to have grown skills and project scope to L5 level after extensive time in the industry could be interpreted by some as poor motivation or career growth planning - their thinking is that if you've been doing the same thing for years elsewhere without growing, you'll tend to be trying to do the same things for years there without growing.
An individual might be trying to get into a FAANG in order to get experience with technically complex projects of a certain scope. A lot of roles out here at non tech or smaller firms are just building and maintaining simple CRUD interfaces. The business domain may be complicated but the tech execution is probably not. I thought the algo gauntlet was a equalizer where exceptional coders could clear the bar regardless of education or work history.
From an interview point of view, they're probably looking for examples of that independence and self-motivation (ie, not just doing what someone told you to do), and also the step beyond just writing the code towards more holistic ownership (things like "created a new test harness along the way", "did a survey of developers", "made sure there was a killswitch", "created a rollout strategy", "convinced another engineer to share review and support responsibilities").
The projects I've worked on in my career haven't been considered in the interview process. They just expected better results on their standardized interviews (algo + system design) compared to a more junior candidate. I don't think the question they ask correlate at all with candidate experience, even for the system design part.
But overall, I think it's an imperfect but fair process.
Edit: I've now found levels.fyi - these are Google's internal progression levels.