The real reason the Second Amendment was ratified, and why it says "State" instead of "Country" (the Framers knew the difference - see the 10th Amendment), was to preserve the slave patrol militias in the southern states, which was necessary to get Virginia's vote. Founders Patrick Henry, George Mason, and James Madison were totally clear on that . . . and we all should be too.
In the beginning, there were the militias. In the South, they were also called the "slave patrols," and they were regulated by the states.
And slave rebellions were keeping the slave patrols busy. By the time the Constitution was ratified, hundreds of substantial slave uprisings had occurred across the South. Blacks outnumbered whites in large areas, and the state militias were used to both prevent and to put down slave uprisings. As Dr. Bogus points out, slavery can only exist in the context of a police state, and the enforcement of that police state was the explicit job of the militias.
If the anti-slavery folks in the North had figured out a way to disband - or even move out of the state - those southern militias, the police state of the South would collapse. And, similarly, if the North were to invite into military service the slaves of the South, then they could be emancipated, which would collapse the institution of slavery, and the southern economic and social systems, altogether.
These two possibilities worried southerners like James Monroe, George Mason (who owned over 300 slaves) and the southern Christian evangelical, Patrick Henry (who opposed slavery on principle, but also opposed freeing slaves).