In my opinion, it's very hard to interpret the first part - "A well regulated militia being necessary to the security of a free state," - without including the second part - "the right of the people to keep and bear arms shall not be infringed."
I think Penn and Teller explained it best. To summarize, they said - rather Penn said while Teller pointed and made faces, etc. - that because a militia is necessary to the security of a free state, and the people had just succeeded in defeating a well regulated militia of the state, and they may need to do it again in the future, the right of the people to keep and bear arms shall not be infringed. In short, it's precisely because the state controls the military that the people should be armed.