I have worked in law since 1985, and is still partially active, even retired.
2 questions, independence and impartiality.
To guarantee the first, one must ensure a fair system of selection and training.
To select a judge, one can hold a contest, an election a draw or a choice by the political power. The last system is the worst.
In France, most judges are professional, chosen by contests, and trained in a special school. Some first level judges are elected or chosen by their constituents, among them the consular judges who sit in the commercial courts, and the prudhommal advisers, who sit on the prudhomme councils. The criminal courts are made up of a mixture of professional judges and citizens drawn by lot.
Once selected judges independence is guaranteed by their irremovability. They are assured to keep their functions and cannot be removed before the term.
For most of the professional judges, advancing in the carrier depends from a special institution, the superior council of the judiciary, a mix of elected judges, of people having a seat as a result of their functions, and nominated people.
The system functions globally well, not perfectly. Some months ago, a lawyer chosen by the president as minister of justice tried to obtain a disciplinary sanction against judge who had displeased him, against the opinion of his services. He got rebuffed as these judges were cleared easily.
Impartiality is something different. It depends from the judge himself. Every one judges with his knowledge, according the way he sees the world, under the influence of his prejudices.
The laws give a judge a big power to balance and choose his decision. there are two limits, appeal and collegiality.
Beyond that, no system is perfect.
Last, the judges are in the world. And they share the bias of the people. they reflect them, without even perceiving them.