I always find it amusing that people think Americans would be so terrible at armed insurrection compared to, say, the Taliban. Because having more diverse geography, vastly superior infrastructure to leverage, higher overall education, better overall physical health, an larger percentage of population with backgrounds in military or civilian law enforcement, and (at the heart of the matter) a vastly superior potential arsenal... those are things that would make Americans bad at that sort of thing?
But I digress.
The 2nd Amendment isn't explicitly "for" opposing one's own government, it's an implicit component to the relationship between a free individual and government in general, and definitely echoes similar concepts found in the Declaration of Independence. What it's for is the ability of the militia (which both at the time and indeed in federal law here today, means the civilian citizenry itself) to be able to competently serve in their role in the "security of a free State". That's nothing that you can't find in the oath of citizenship people still take today, which in this language mirrors that which people swear going into the regular military -- "...that I will support and defend the Constitution and laws of the United States of America against all enemies, foreign and domestic..."
The "militia purpose" discussed in Heller and understood by the Framers was exactly that -- for the event that the unorganized Militia has to muster to protect the body politic, they will be able to do so with the competence and professionalism of regular military, i.e. to be "well-regulated", and that for that reason the right of the people* to keep and bear arms shall not be infringed.
*this phrase, "right of the people", appears in three places in the Bill of Rights, in the 1st, 2nd, and 4th Amendments. Without fail, in every context, this phrase has been understood to refer to an individual liberty interest of citizens. It was undoubtedly chosen intentionally for exactly that kind of uniform interpretation.