It is also clear that the right is a right of the people.
It doesn't really matter what is in the first part, all that matters is the right of the people to keep and bear arms. The first part could have said anything and it wouldn't change it.
“Peanut butter and jelly sandwiches, being necessary to feed Elvis, the right of the people to keep and bear arms shall not be infringed”
It might be a dumb reason for doing so, but it doesn't change the intent of the amendment.
More like, A good supply of trained knights being necessary to the defence of the kingdom, the rights of the noble classes to keep and bear arms shall not be infringed.