When choosing justices on the one hand you want to choose them meritocratically and on the other hand, you want that the views of the population are well represented.
For justices in lower courts who are just supposed to rule in the way the higher courts would, you can just pick them meritocratically without problems if the higher courts are selected in a way that represents the view of the population.
When speaking about “merit” of judges, the useful for what that means in practice.
For low-level judges, that often means exam scores. In merit-based systems, you need good exam scores to become a judge.
For experienced judges you can measure merit by how much of their judgements get overturned by higher courts. A judge who constantly makes judgements that get overturned is bad at seeking legal consensus.
In common law jurisdiction you could also measure how often the opinion of the judge on cases get cited by opinions from other courts.