This can be solved by impeaching judges who refuse to follow the law.
Furthermore, we have seen numerous examples where unelected judges force their values down the throats of the majority (such as the Pledge of Allegiance 9th circuit judges) without committing some impeachable offense.
OTOH, our informed local voters sent down to defeat our two most ethically-challenged local judges and re-elected our other hard-working judges. All in all, the elected judiciary works.