There is an 80-year old astrophysicist at the local government research observatory here. The government doesn't pay him anymore, but he has his own grants. He is almost certainly the most productive person at the facility, running circles around people half his age.
And he does everything. Is a leader, guide and mentor for all the young scientists. He does serious intellectual work. Sometimes spends all day out in the sun, improving/fixing/maintaining telescopes. They held a conference in his honor last month.
The lesson is not to judge people's productivity using just their age as the gauge.
He's a professor at Caltech and did Nobel laureate-level work. He might be less productive than his prime and still be competitive with other professors, particularly since he brings deep understanding of the history of approaches in his field.
Why would it be illegal? It clearly is something he wants to do, and something his employer wants him to do.
In the US, various forms of age discrimination against people over 40 have become illegal over the years, including mandatory retirement. So the law is moving the other way.