Well, they pretty much spelled it out:
A well regulated (controlled) militia (army) being necessary to the security of a free state, the right of the people to keep and bear arms shall not be infringed.
Everyone tries to contort the Second to mean this or that, but the whole idea was that the people would retain power over the army by sheer force of numbers (as opposed to martial skill) so long as they remained armed.
The security of a free state could not be ensured any other way if there was to be an army at all.
In the context and vernacular of the Eighteenth Century, "well-regulated" meant "well-organized, well-trained and well-equipped".