According to Second Amendment historian Michael Waldman, the amendment's roots actually go back to England, where there was a longstanding tradition of owning guns for the purpose of serving in local militias. Males between the ages of 16 and 60 were expected to train with the militia, and they were required (not merely allowed) to bring their own weapons.
In the American colonies, where potential security threats included Native Americans and the French, militias quickly became an important institution. Again, the citizen militiamen not only were required to join, but also had to buy guns as well. If they couldn't afford them, the militia would lend them the money. Although every white man was supposed to participate, the wealthy and the well-connected found ways to wriggle out of service.
But when the colonists started to resist England's efforts to impose taxes upon them in the 1760s, the American militias started to take on a different purpose. They became an integral part of that resistance — an armed citizenry that was prepared to challenge the British. In the war for independence that ensued, the militias played an important role.
Colonial legislatures began enacting new constitutions that enshrined the militias and their right to bear arms. Virginia's 1776 Declaration of Rights, for example, specified that a "well-regulated militia, composed of the body of the people, trained to arms," was necessary for the colony's defense. Pennsylvania similarly passed a charter decreeing that "the people have a right to bear arms for the defense of themselves and the state" [source: Waldman].
Once America won its independence and the framers began to work on the U.S. Constitution, the role of the militias became an issue. Some saw the new federal government's power to raise an army as a potential threat to liberty and wanted the states to continue to have their own armed forces as well. In 1789, when James Madison drew up his proposed changes to the document — which evolved into the Bill of Rights — he included an amendment that specified that the people had the right to bear arms, and that "a well armed and well regulated militia" was in the interests of a free country. Madison also included in the amendment an exemption for those who didn't want to serve in the militia because of their religious beliefs.
That exemption would become controversial when the amendment was considered by the House and Senate. Ultimately, a Senate committee reworked the amendment, removing the "well armed" and the religious exemption and creating the wording that ultimately made its way into the Bill of Rights [source: Waldman].