Because some people value elections over impartiality. Note that in the federal system, no judge is elected. Judges are appointed by the president and confirmed by the Senate.
In states, judges may be appointed in similar fashion or elected. Appointments have the advantage of greater impartiality but can leave judges out of touch. Also, without a way to easily replace a judge, there were concerns that appointed judges were too easily corrupted. In particular, Thomas Jefferson was concerned that judicial decisions were blocking the will of the people.
Example source.
Now, as to whether that has gone too far, you'll have to make up your own mind. The United States is exceptional in the number of elected judges. Perhaps a different system would be better.
Impartiality
Why are appointed judges more impartial than elected judges? One argument is that it is a result of increased distance. Appointed judges are picked by politicians who are beholden to voters. Elected judges are picked by voters directly. But this distance is narrow. The people who appoint judges are responsible to the same interests as the elected judges.
A greater reason is that appointments tend to be to lifetime terms while elections have more limited terms. The greatest threat to impartiality is not the last appointment or election but the current one. While running for election is when judges are most vulnerable to influence. They need not just votes (from popular decisions) but money. Even if the judge is incorruptible, the nature of elections means that the choice between two incorruptible judges is corrupted by money and votes. The popular judge with many contributions is more likely to win. So even if the judge's beliefs are honestly held, the election can itself effectively choose the result of a case.
Elections
Elections provide responsibility rather than impartiality or independence. Elected judges aren't independent of the voters who chose them or the contributors who supported them, but they are responsible to them. The voters can remove the offending judges.
People are often more concerned about getting rid of judges than making them more impartial. This negative feedback system may make ending judicial elections difficult. The bad judges elected make voters feel that they need ways to remove judges, which promotes judicial elections, which promote bad judges.
Founding fathers
The founding fathers of the US chose appointment over elections, implicitly picking independence over responsibility. That makes it difficult to answer your question in terms of the founding fathers:
If judges are supposed to be impartial, why are some elected if that risks them having biases towards their constituents?
The founding fathers did not choose to have any judges elected. The closest would be to talk about the principle of federalism, which left decisions about choosing the majority of judges to the states. But there is very little about that in terms of picking judges. Federalism leaves such decisions to local control in general, not just in regards to judges.
The specific founding father, Jefferson, after the nation was founded and he was living in it, said that judges were problematic because they were independent. So when the government switched from being Federalist (implicitly under George Washington and explicitly under John Adams) to Democratic Republican, the judges did not change immediately. After twelve years, the courts were filled with Federalist judges with very few vacancies.
The Articles of Confederation were written in 1776 and replaced by the Constitution of the United States in 1787-9. So they weren't impacted by Jefferson's subsequent reservations. But state constitutions were written later. Only thirteen of the fifty states were states in 1789. The rest were added later. In addition, there hasn't been a rewrite of the federal constitution since 1789, but the states have been able to do so more often. So state constitutions aren't necessarily subject to the opinions of the founding fathers.
The founding fathers thought that judges and Senators should be appointed. Judges by the president with the consent of the Senate. Senators by the states. The nineteenth amendment changed that for Senators, making them subject to direct election. Federally that never changed for judges. But at the state level, those rules were easier to change.
Ballotpedia says
Keeping independence and accountability in mind, these founders established a system whereby the President would appoint federal judges with U.S. Senate consent. Before the mid-1800s, nearly all states admitted to the Union selected their judges by this method of gubernatorial appointment with legislative confirmation as well, though some opted to select judges by legislative vote alone. Then in 1832, Mississippi became the first state to implement judicial elections. New York followed suit in 1846, and a rapid shift occurred as state after state joined them. By the time the Civil War began in 1861, 24 of the 34 states had an elected judiciary, and every state that entered since provided for the election of some—if not all—of its judges.
Scholars attribute the move toward judicial elections to a variety of factors, including:
- concern over an independent judiciary, especially after Marbury v. Madison established the judiciary's power as equal to that of the executive and legislative branches,
- imitation by the states,
- belief that judges at a local level should be accountable and responsive to their communities, and
- the growing popularity of Jacksonian ideals, which touted the importance of the "common man's" voice.
Their chief citation for this is NYU Press, "The Study of Judicial Elections" (PDF).
Note that now only twenty-two of the fifty states have judicial elections. This is fewer than at the time of the Civil War even though there are now more states overall.