The U.S. Supreme Court announced a new rule on judicial bias in 2016. Although the rule might not apply to lots of cases, it highlights the fact that judges are supposed to be impartial (neutral).
Williams was convicted of a 1984 murder and sentenced to death. His lawyers fought the conviction and sentence for 26 years, arguing that the prosecutor had obtained false testimony from a witness and failed to disclose exculpatory evidence. Eventually, a Pennsylvania judge stayed the defendant's execution and ordered a new sentencing hearing. The state then asked the Pennsylvania Supreme Court to vacate (set aside) the lower court's stay and reinstate the death penalty, which the supreme court did.
Before the Pennsylvania Supreme Court made its decision, Williams filed a motion for the chief justice to recuse himself (not participate in the decision). Why the recusal request? Because the chief justice had been the district attorney who gave official approval to seek the death penalty against Williams all those years ago. The chief justice denied the motion for recusal.
The case eventually ended up before the U.S. Supreme Court. Basing its decision on the 14th Amendment's Due Process Clause, the U.S. Supreme Court concluded that the chief justice had to be recused. It commented that a likelihood of bias by a judge that "is too high to be constitutionally tolerable" requires recusal. More specifically, it decided that a judge who has had "significant, personal involvement as a prosecutor in a critical decision regarding the defendant's case" must recuse him or herself. A person cannot serve "as both an accuser and adjudicator in a case." (579 U.S. 1 (2016).)
If you want to know about your options as a criminal defendant, consult a lawyer with experience in your jurisdiction. Rules and practices vary. For example, lots of states have rules on judicial recusal that are stricter than the Williams holding.