A federal clerkship is a coveted position. Judges wield vast amounts of power in selecting their clerks–so vast that fear of reprisals have forced many clerks to stay quiet in the face of abuse. I even proposed eliminating clerkships as a way to eliminate this imbalance of power. But so long as federal clerkships remain, judges will still exercise nearly-unfettered discretion over who they hire.
At a minimum, clerk candidates should meet certain legal competencies: careful reading, clear writing, and sharp acumen. Beyond these checkboxes, the decision to hire one candidate over another will often come down to fit–the fit between the judge and the candidate; the fit between the candidate and other clerks in chambers; the fit between the candidate and clerks in other chambers (inter-chamber shuttle diplomacy is an undervalued attribute of clerking); and so on. Every judge will understand "fit" differently.
Some judges will also hire based on a candidate's potential for success in the future. We know all about the so-called "feeder" judges who hire clerks with an eye towards recommending them for the Supreme Court. When a Justice hires such a super-star, the "feeder" judge looks good! So "feeder" judges have every incentive to identify clerks–who often only finished 1 or 2 semesters of law school!–with the potential to go upstairs.