First you should find some correlation between law school grades and competence of the lawyer.
https://www.alanet.org/legal-management/2023/february/column...
> When looking at on-the-job performance, our internal data — based on thousands of reports from actual attorneys at some of the top law firms — tells us that GPA on average has a 2.2% predictive validity. Meaning that GPA, the thing that the LSAT is meant to predict, explains very little. When we look directly at the LSAT, we see an even smaller correlation of 0.9% on average.
Nobody did a correlational study between electability and judge or prosecutor competence either.
Would you agree knowledge of the law is a better, if still imperfect, indicator of ability as a judge or prosecutor than being merely appealing to voters?
In any case, I think a competitive exam is better than law school grades. It allows for applicants who didn't do so well in law school but got better later.