I would reply that we are a republic and not a democracy; the best example I can think of in recent history might be the Jim Crow Laws here in the south. Imagine such a thing being debated on a federal level...A representative from an overwhelmingly white district may have had a constituency that was 95-5 in favor of perpetuating the laws...yet, if that representative did what they knew to be the moral and right thing, they would vote with the 5% opposition.
The problem with your analysis is that I am addressing issues of policy - that is, the difference between one legitimate course and another legitimate course.
You are bringing up a matter of law - that is, the difference between an illegitimate course of action and a legitimate course of action. Our lawmakers can't pass an illegal law - that's an illegitimate course of action.