When the second amendment was written, average citizens used their own weapons when called up for military duty (not exclusively, but largely). These militias were instrumental for winning the revolutionary war. A citizen army was seen as one of the guards against an oppressive government.
So, the 2nd amendment was written to specifically address that concern. The goal was to keep the federal government in check.
But it should also be noted that the amendment specifically states that the militia should be well-regulated, meaning that it was run by the individual states (not the federal government). And guess what? All US states have 'National Guards' that do precisely this.
The problem is that the 2nd amendment, like all others, is not absolute. You do not have freedom of religion to the point that human sacrifice is allowed. You do not have freedom of speech to the point to yell 'fire' in a crowded theater (interesting story on this one, by the way). And you don't have the right to have a personal military stockpile.
For many people, guns are a necessary tool of their jobs. On a farm, they are simply one of the many dangerous tools that are used on a daily basis. Historically, hunting was a means of income and a way to put food on the plates. That is less so today, of course.
The current difficulties have to do with how to regulate gun ownership in such a way that those who are unstable, untrained, and irresponsible are not allowed to own these dangerous pieces of machinery.
At the very least, I would expect every gun owner to be part of a well-regulated militia that gives rigorous training on the use and misuse of their devices and has regular mental health screening to be sure the person is stable enough to continue to own their weapons. That would satisfy the 2nd amendment and lead to a much healthier attitude towards guns.