The only interpretation that would make sense at all would be taking the first two parts as an absolute construction, and the the other two as the main clause. With modern punctuation, it would look like this:
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 part in italics is an absolute construction, as it is still used in modern English, to be paraphrased as because a well regulated militia is necessary to the security of a free state...; the main clause speaks for itself.
It seems some modern-day politicians have committed the error of interpreting this sentence in an unhistorical manner: the use of commas has changed quite a bit since the time this sentence was written, and it should be read according to the punctuation conventions of that time.
The use of commas wasn't as well established in 1791 as it is now: the connection between pause and comma was much stronger (commas now mark about 50 % pause and 50 % syntax, depending on the comma). In the 18th century, commas could be used where one heard a pause, more or less, regardless of syntax. In modern English, the comma before being forbids taking what comes before as a single absolute construction together with what comes after; but that does not apply to the 18th century. We shouldn't pay those commas much heed except as marks of pause. It is better to read the sentence out loud and see how we can make sense of it. Any other reading than the above seems vastly inferior.
That said, I find it mystifying why anyone should want to treat any text as an eternal truth, ignoring the historical circumstances that led to its creation. But I suppose this mystery isn't relevant here.
[Edited:] The fact that punctuation was quite different may be observed in the fifth article of the same Bill of Rights; according to most modern grammarians and style books, at least the first two commas would be superfluous and wrong:
No soldier shall, in time of peace be quartered in any house, without the consent of the owner, nor in time of war, but in a manner to be prescribed by law.
The following is from Punctuation in English since 1600 (archived version), a little essay by John Wilkins of Ohio State University. It has presumably been incorporated into the Encyclopaedia Britannica. The author seems knowledgeable and reliable.
Excessive punctuation was common in the 18th century: at its worst it used commas with every subordinate clause and separable phrase. Vestiges of this attitude are found in a handbook published in London as late as 1880.
Furthermore, Wikipedia mentions that, at the time, the States passed a version of the Bill that had the exact modern punctuation: the version in question is the one that was passed by Congress.
This shows how different and varying the use of commas was in the 18th century. Only after 1900 did most writers' punctuation come close to ours, though the comma's move from pure pause to mainly syntactical mark can be traced back to the 17th century, or even earlier.
[Edited again:] By contrast, some anti-gun politicians have tried to read the sentence as follows:
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.
They take the two phrases in brackets as modifying a well regulated Militia: "a well regulated militia, which is necessary to the security of a free state—in other words, the right of the people to keep and bear arms—shall not be infringed."
Following that interpretation, it is this well regulated militia of a State that is not to be infringed upon by the federal government. The italicized phrase about the arms is then to be taken as a non-essential, further explanation of what this militia is about. This reading is inferior for several reasons:
- It is based on an artificial and incorrect reading of 18th-century commas.
- The verb to infringe normally does not take an organization as its direct object, but rather a rule or right. Taking the right to bear arms as the object is much more obvious.
- Taking the italicized phrase about the arms as an apposition is hardly possible:
- it modifies a noun phrase (Militia) that is too far back;
- it is not a logical apposition to Militia: a militia is not a right but an organization.
- If you consider the historical context, it is quite obvious what the purpose of this article was. There had been debate about whether civilians should be allowed to bear arms or only the police and the army. If only for the many isolated communities in the west, it was impracticable to have a sizable police force to protect the people everywhere; this and other considerations led to the decision to allow civilians to own and use guns. Because wild shootings and anarchy were not wanted, it was probably envisioned that well trained and regulated militias should use those arms, not each citizen protecting himself; but the Bill of Rights wasn't meant to go into the matter in much detail: for now, considering the necessity of locally organized armed groups, it was deemed best for the federal constitution not to forbid civilians to bear arms.
The incorrect reading can be found in the Yessky Brief (September 1999) for U.S. v. Emerson, 12 note 4:
The grammatical effect of these two unusual commas is to link "A well regulated Militia" to "shall not be infringed" to emphasize, in other words, that the goal of the Amendment is to protect the militia against federal interference.
Language Log cites the above and agrees that it is nonsense.