Specifically in the Heller decision in 2008, the Supreme Court ruled that the operative clause of the Second Amendment (“the right of the people to keep and bear Arms, shall not be infringed”) is controlling and therefore refers to a pre-existing right of individuals to possess and carry firearms for self-defense. They ruled that the Framers believed the right to bear arms already existed and therefore the Framers were simply recognizing it formally with the Second Amendment. After all, before the Bill of Rights was written and ratified, the people certainly had the inherent right to own and carry firearms in the American Colonies. To solidify this point, the Court based this ruling on the bare meaning of the words in the clause, along with the usage of “the people” elsewhere in the Constitution and historical materials that explain the clause’s original meaning.
The majority also ruled that the prefatory clause of the Second Amendment, which says that a “well regulated Militia, being necessary to the security of a free State,” refers to a well-trained citizen militia, which at the time “comprised all males physically capable of acting in concert for the common defense.” The Court noted historical materials supporting this interpretation, including “analogous arms-bearing rights in state constitutions.”
This is pretty straightforward stuff. It also explains why during most of American history an exhaustive analysis of the Second Amendment wasn’t necessary, as the meaning of each word in the Second Amendment was too obvious to question. The Second Amendment wasn’t even debated until the progressive era in the late nineteenth century and not really disputed until well into the twentieth century. This is why the fundamental constitutional question wasn’t answered by the high court until 2008—some 217 years after the Bill of Rights was ratified by the states.
For more, check out Saving the Bill of Rights.