The purpose of the second amendment was not to overthrow the government, you fucking moron. The point of the second amendment was very very much linked to a major issue the nation had at the time: They had a standing army, and didn't like it.
Alright, a little bit of context into this - The US, as it was originally founded, didn't have a standing army. Hell by the time the Constitution was being ratified, the army of the united states was... a single regiment. Of 625 men. On a good day.
Many of the people involved in the revolution (and in the constitutional conventions) loathed and hated the idea of a standing army in a republic. A standing army was the thing of dictators and kings and just not good (Nevermind that they needed to have a standing army to actually fight against the British). Also they knew their history - a standing army let Caesar rise to power. A standing army is also very, very expensive, even in those days. Firstly, you have to pay wages (and the government was pretty fucking broke at the time), you have to have a bunch of people willing to volunteer for a standing army - or you need to press them into service - you need to feed them, to clothe them, to supply them, and to keep them under arms. You have to train them, and that's also not easy or cheap. The American Revolution indicated a tendency in the average American that had plagued the Roman Republic as well - nobody wants to leave their home behind to do any kind of extended campaign. This was a major and thorny issue.
Now, enter the concept of the militia. The militia is essentially self funding, self training, and were something almost every colony had. It's Jimothy And Timbert, who know how to load a gun, fire it... and that's about it. They could have some heavier weaponry like cannons, but not always. Hell, some might have pikes. A lot of their guns are also stored at a central armory in a town, where everyone who is part of the militia will go and form up if called into service - they don't always keep them in their houses if they're in a town. Some own their own firearms, but usually it's a rich guy who foots the bill for a lot of this. The quality of a militia could also vary wildly from town to town, location to location. Theoretically, every adult male is in the militia, though in practice not really. Theoretically, they're all trained, in reality said training might be literally 'here's how to load and fire a gun' if that. Plenty of these militias were basically private armies in all but name (especially in the south), though every state had a public one too.
These militias during the revolution were the foundation of the standing army and had a real tendency to just... go home. Despite this, they were the darlings of the anti-federalists, proof to them the spirit of the revolution was going to always be defended by the citizens. And here was where some of the major issues when drafting the constitution came about. See, there was this thing that happened called 'Shay's Rebellion,' which essentially was a group of people disgruntled with taxes that tried to overthrow the government of Massachusetts. Only about 10 people died, a few hundred were arrested, and central to the forces on each side were local militia forces. The central federal government had no real army as mentioned before to actually do ANYTHING about this, and the anti-federalists saw this as a feature, not a bug. Enter the amendment issues, and the constitutional conventions. There was a massive argument about if the national government could even request troops from the various states, or raise its own army.
Essentially the 2nd amendment is a massive, massive concession to the anti-federalists, while still giving the Federalists the ability to actually have a military . Why? Look at the language. The Anti-Federalists were absolutely fucking terrified of the idea of any centralization of power, and were paranoid as fuck about it. One of the big fears they had was that any army of the United States would mean an end to the militias entirely (Some anti-federalists were also against the idea of any organized militia but these were the real wacky guys of their era, basically ultra libertarians) and Hamilton addresses this in the Federalist papers (number 29) essentially saying that 'hey the militias are fine and we're going to keep your ability to have your little private armies, see this amendment.'
The first thing mentioned in the amendment is the militia. This is is by design. The militia question was a massive sticking point during the drafting of the primary constitutional articles. Private militias were something a lot of anti-federalists feared would be simply taken out of the picture. That being said, a bit more details have to be given about all of this, and an examination of the language too. 'Well Regulated' is exactly what it means. Essentially, the 2nd amendment was never a cut and dry 'EVERYONE GETS AS MANY AND ALL TYPES GUNS THEY WANT TO OWN' at all. The amendment mentions militia first, because at the time, the US army is pretty much a thing on paper and not in practice. This would change drastically later, but at the time, everyone knew that to even pretend to be a state with any kind of defensive force, they had to tolerate these militias. "Shall not be infringed" when you consider the rest of the text is a bit clunky, and sort of comes down to the idea of 'yeah sure you can form a militia with an armory that's a protected thing, but the federal government gets a say in what actually constitutes that.' The Anti-Federalists rejoiced because it proved the power of the people and idealism and all that wonderful freedom crying eagles and so on and so forth. An army of the people (people being white land owning men) would defend the rights of the people (white land owning men) and everything would be hunky dory.
There were a lot, and I do mean a lot of implicitly known limitations to the second amendment at the time. Firstly, the phrase well regulated militia was intentionally designed to keep the ability of the various states to regulate who they defined as the militia. This was very important in the south, as every single southern constitutional delegate would have walked right out the fucking door if this amendment applied to all free men. The emphisis on a well regulated milita was by intention, meant to be able to allow the states to exclude whoever they wanted - in the case of the south, free blacks. The biggest use of any militia in the South was at the time, as a deterrent to any kind of slave uprising, and to catch escaped slaves. The second amendment was a massive bone thrown to the south by Madison which isn't too much of a surprise (He was a Virginian). Secondly, the implication of the amendment was also that the federal government would take responsibility to arm and regulate the militia if they wanted, and request or stand them down as needed from the various states. The second also gave the states a bit of an 'out clause' against another part of the constitution, just in case. The fear of government tyranny resulting from having a standing army was alive and well at the time, and the second was certainly meant to assuage the fears that the nation could fall to such an action. Having a large militia and a tiny standing army meant that theoretically, the militias would win.
All this being said, the original language of the amendment is kind of telling: it's basically an amendment meant to allow the US to conscript people as needed. No, really, here's Madison's original submission.
The right to bear arms in Madison's original version is very much linked to military service. Again, this is to appease the anti-federalists by saying 'Hey we don't need a standing army if we can just make the population an army as needed'. From the start, the second was very much intended as a military thing, and an attempt to have a standing army without actually having a standing army. There's more regulations that then got issued, for example the government tried to standardize the bore of every musket made in the future, and mandate that everyone buy a gun if they were a white man over 18. This... didn't really work out that well, and the Whiskey Rebellion of 1794 poked more holes in the idea of using a local militia for an army when again, local militias were flocking to the rebels and others weren't keen on getting involved. This was really a massive problem, but kinda got ignored, as the Anti-Federalists were starting to gain more power and any attempt to change the constitution was not going to be easy anyway - the thing was still quite new and a compromise document in many ways. Besides, what could possibly go wrong with basing our defense around random citizens with guns with little standardization? Nothing at all, surely!
Enter the War of 1812 where said private militias (and the state militias) are the primary forces of the United States. And holy mother of fucking god, does it go horrifically wrong for the United States. The War of 1812 pretty much kills the concept of basing national defense around the state and private militia, which was sort of what the Second Amendment said would be the case. Why? Well for starters, plenty refused to move away from their local communities to you know, actually help their neighbors. Others just showed up, shot a few times, went home. Some stood and fought but well, they had pretty much no training and their ability to actually stand and fight wasn't very good. Well funded private militias didn't do much good either - the brits went 'Hey, free cannons' half the time they faced them, and the other half of the time still usually won. The small standing Continental Army performed very very very well, especially compared to the average militia force. Despite the British not bringing their top tier professional forces, they'd wiped the floor with every militia sent against them, even when out numbered. There were about half a million militia mobilized in the United States during the War of 1812. The British sent originally 5000 men... and then a bit over 50,000, as the US rapidly built up an actual standing army out of necessity.
Despite all this, the second amendment remained unaltered, because nobody bothered to come back and sit down and think 'OK let's take out the militia part of this' or tightening up the language. It had been written down twenty years ago, and might still be relevant in the future - plenty of people were deliberately trying to ignore the complete failure of basing the entire defense of the nation around people who bought their own gear. The start of viewing the constitution as a civic religion also had an impact on this, as any kind of change to the document started to be seen as going against what the founders wanted, Besides, the obvious problems with the original document had been patched up with the 11th and 12th amendments (In 1794 and 1803), and nobody wanted to touch already made amendments. Could you even do that? How? Another amendment? Was that constitutional?
tl;dr: The second amendment has a complicated history and doesn't just boil down to 'BUT BUT MUH GUNZ'
EDIT: The current interpretations focusing on "shall not be infringed" rely heavily on the original draft that Madison had in the amendment, which was quickly altered to have the militia be the first and primary stated purpose of the amendment (though they argue that it isn't the primary but simply the introduction reasoning for the whole right to bear arms shall not be infringed which is playing semantic games about intention that a lot of 'Originalists' like to try and pull to justify whatever they want while claiming the text supports it even if it might not.) Shall not be infringed is hard to interpret because infringement in the sense of the original language was having no weapons what so ever, not not having private weapons... maybe? It's complicated, not very clear, and I don't know if that's intended to give the states a way to circumvent the government and have armies of their own, which isn't an implausible interpretation. The intentions of the founding fathers certainly indicate that they wanted people to be armed, but the reason why is couched firmly in revolutionary ideology for some, for practicality for others, and a wide variety of reasons that really only applied to the odd situation the country was in when the constitution was being written and ratified. The amendment was also written before the War of 1812 - which pretty much shattered Madison's faith in any kind of militia compared to a standing army for the defense of the revolution and nation. Basically, originalists are full of shit because they try and ignore the context to the 2nd Amendment and what was implied about it at the time of its writing. It's dumb, and even dumber still when you consider the Militia Acts, which they like to try and ignore, which firmly defines what the militia is, even if it isn't in the constitution - which gives you an idea of the ACTUAL intent of the Founders when they wrote this, namely the
Acts of 1792 - just a year after the Constitution and its amendments were ratified. The first gives the federal government the power to actually call on the militias, something not implicit in the constitution outside of the article involving the feds getting to raise an army. The second goes into detail on the actual regulation of these state level militias, down to what arms they should have, what roles they should have, etc. It already excludes people from the militia (one of the primary arguments used by originalists is that the militia was understood to be everyone in the 2nd amendment, which again, bullshit), and thus from having arms... or from regulation of said arms, if you're feeling spicy.
When combined with the later act of 1903 which established the concept of an organized (the national guard) and unorganized militia (the general population), the idea that the government can regulate what arms the militia has access to isn't out of the question, especially when you consider the government tried to do that just after the 2nd Amendment was ratified. Seriously.