This paper explores how political polarization among voters influences the quality of elected officials, with a focus on judges. In our model, legal professionals decide between staying in their current legal careers or running for judicial office. Intrinsically motivated legal professionals derive inherent satisfaction from practicing law. This has two implications: first, individuals with higher intrinsic motivation prefer to spend time on their current careers over electoral campaigning; second, if elected, they exert more effort on the bench. In a polarized electorate, voters decide mainly on candidates' party affiliations, reducing electoral campaign effort in equilibrium. Hence under higher polarization among voters, candidates with higher intrinsic motivation are more likely to run for office and to get elected -- increasing judicial decision quality. We take the predictions to data on the performance of all U.S. state supreme court judges working between 1965 and 1994. We find that in states with partisan judicial elections, judges who joined the court when polarization was high write higher-quality decisions (receiving more citations from other judges) than judges who joined when polarization was low.