to the United States constitution states, in full, "A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed."
The operative clause - "the right of the people to keep and bear arms shall not be infringed" - seems fairly clear. But what's the first half of the amendment doing there? What does it mean that a militia is necessary to the security of a free state? And why don't unfree states need militias, too?
The answer, of course, is that militias - or more bluntly, having arms in the hands of the people - is one of the things that keeps a state free. The founders who wrote that amendment had just finished winning a revolution - one that wouldn't have succeeded if the government had a monopoly on weaponry. And even when the peoples' weapons aren't actively used, their mere existence might deter repression that the government might otherwise be tempted to engage in.
That's why it's amusing to read the oral arguments in the first Second Amendment case to reach the Supreme Court in 70 years. Most of the justices are aware of this issue, and perhaps even agree that personal weapons are an important check on the government - but none of them want to say something that could be misconstrued as "it's okay to shoot at us".