First, HR is never going to tell you any reason other than generalities about why you were not selected to be interviewed. It is their job to protect the organization, not to make you happy.
Next there are two kinds of fit that are used to determine who to interview. The first is technical, does the person have the actual skills to do the job according to what I see in the application.
The second, and more often more important, is about cultural/personality fit to the organization. While this is often determined in the interview, sometimes you can see if from the resumne or from people who work there who know you and this comes into play when the resume is evaluated.
Sometimes a organization even has an informal list of people they don't ever want to work with. This is especially true in professions where everybody knows everybody else such as in academia where the academic subject is fairly specialized, everyone meets at conferences and very few people have the qualifications on paper. In fact if they were familar already with your thesis, perhaps they were not impressed by your conclusions or perhaps they know their work is going off in a differnt direction.
The person who works well individually is going to fit some organzations better than the great team player and vice versa. There are serious organzations and fun ones and different people fit them differntly. There are managers who like conflict and people pushing their ideas and managers who want only yes men. Some managers want to work with people with a stronger technical background than they have and some do not. Some like diversity of ideas and some prefer everyone to have roughly the same perspective on things.
The organization gets to decide what personality traits or attitudes are the best fit for this particular work group.
They have to the right to unilaterally reject any candidate they don't think will work well with the current team. This is particularly true when there is a current employee who has actually worked with this person in the past. Many companies in fact will turn down great candidates if only 1 person says no. Many copmanies ask employees who worked at the same places as a candidate if they know him and what they thought. It is a legitimate part of the process. Many people have gotten turned down as a result of the poor reputation they have with former co-workers or in their technical community. Many people have gotten the job when they are less qualifed on paper because of the great reputation they have with former co-workers.
If there is someone who already dislikes you at that organization, it could be that is the reason you were turned down. And that is not bad faith. That is a legitimate way to evaluate candidates. Current employees should not be forced to work with people they arleady know they cannot get along with.
It also could be the manager turned down hiring you for another reason such as others he saw as more qualified when reviewing the resumes. Just because you feel extremely qualified doesn't mean that people reviewing your resume might not see others that seem better to them and only want to interview the top 3 and you were 5th. And what you viewed as a minor part of the requirements might actually be the most critical to the hiring manager.
So you don't know why they thought you were not the most qualified. Perhaps you genuinely were not based on their evaluation criteria.
And often more than 50% of the applicants might meet the listed job requirements (for some jobs 90% or more), they are never going to interview all of them unless there were very few applicants.
You also don't know that HR rejected you. The emails would always come from them. The hiring offical may be the one who chose not to interview you.
Finally, you need to stop this habit of thinking things are unfair. The world is unfair to everyone at times. They don't owe you a job. There are lots of jobs, you wil be rejected for many of them when you apply becasue they can't hire everyone who applies. I assure you that for every job you have gotten or school you have been accepted to there was some other candidate who thought he was unfairly rejected because he was highly qualified.