I hate to swim against the tide, but several years ago I took an interest in the subject of militias in the Constitution. And after a lot of reading and listening to arguments, I came to believe that the militia clause in the 2nd Amendment, however badly worded, should not be construed to mean that only active members of the state militias (now the National Guard) had a right to own firearms. Rather, I think it’s more likely the Second Amendment protected the right of individuals to own firearms so that the state militias could not be disarmed by the federal government. I know that doesn’t make much sense now, but I can see how 18th century men might have seen it that way.
The original state militias were compulsory, meaning all eligible men were required to register. They were also often self-armed, and federal regulations passed by the original Congress stipulated what sort of musket the registered militia members were supposed to maintain. In reality these regulations were not followed all that well. Some states took their militias seriously and some let them go to rot. There are all kinds of stories of men drilling with broomsticks and cornstalks instead of muskets because they didn’t own muskets. Militias tended not to be very good at actual warfare. However, in the early 19th century drilling competitions between militia units were a popular spectator sport.
Anyway, long story short, the way the original state militias were conceived, the ability of citizens to purchase and possess firearms was essential if the state militia was going to be armed.
I haven’t read the Heller decision myself, so I don’t know how the majority of the court argued it.