Is it illegal for a company to hire a younger less qualified person for a job you apply for?

Not at all. A company can hire anyone who applies and meets the requirements for the job, regardless of expertise or skill.