From Mises.org:
Fearful that a large federal military could be used to destroy the freedoms of the states themselves, Anti-Federalists and other Americans fearful of centralized power in the US government designed the Second Amendment accordingly. It was designed to guarantee that the states would be free to raise and train their own militias as a defense against federal power, and as a means of keeping a defensive military force available to Americans while remaining outside the direct control of the federal government.