Now, you are intentionally omitting. The militia purpose is not the exclusive purpose, it is only one component.
Again, the Cornell page describes the ruling:
"Coming back to the Court’s initial declaration that the two clauses must “fit” together, the majority concluded that the two clauses fit “perfectly” in light of the historical context showing that “
tyrants had eliminated a militia consisting of all the able-bodied men . . . by taking away the people’s arms.”
22 Thus, the Court announced the reason for the
Second Amendment’s codification was
“to prevent elimination of the militia,” which “might be necessary to oppose an oppressive military force if the constitutional order broke down.” 23 The Court clarified that the reason for codification does not define the entire scope of the right the Second Amendment guarantees.24 This is so because, the Court explained,
the Second Amendment codified a pre-existing right that included using firearms for self-defense and hunting, and thus the pre-existing right also informs the meaning of the Second Amendment.25"