The historical reason, as far as I can recall, is that it's an attempt to make the judiciary independent. If judges were elected, they'd have exactly the same biases as the other elected offices, which means they'd be a less effective check-and-balance system. That also leaves aside the many, many ways you can corrupt an elected official that cannot be used for an unelected official.
In most western democracies (and certainly in Westminster-style democracies, which I know best) the judges are bound by a certain set of rules that limit how activist they can be: specifically, a constitution. They're required to make findings of law, nor findings of morality, so they can't just manufacture law or destroy law as they see fit: they need a different law they can point to which overrules the one in question. Hence the US Constitution, which acts as the highest law in the land. A judge will always reference their decision, in the end, to an established law (or the constitution).
Conversely, elected officials are empowered to _make_ law. Less true in the US (where the constitution binds the hands of the legislature and executive), but very true in Westminster systems where parliament is the supreme authority.