The phrase was put in the amendment to gain support of several states strongly committed to a citizen militias for defense of the country.
The fact is most people had no real interest in the right to bear arms because in those days firearms meant muskets which were lousy for self defense, very inaccurate unless you had a long rifle and were too costly. About the only real use was in volley firings which is how muskets were commonly used in militias. The reason for the 2nd amendment 230 years ago and today are completely different.
Which, once again, simply begs the question as to why it does not read.......
"A well-regulated Militia, being necessary for the security of a free State, the right of the
Militia to keep and bear Arms, shall not be infringed."
"A well-regulated Militia, being necessary for the security of a free State, the right of
its soldiers to keep and bear Arms, shall not be infringed."
"A well-regulated Militia, being necessary for the security of a free State, the right of the people
in the Militia to keep and bear Arms, shall not be infringed."
"A well-regulated Militia, being necessary for the security of a free State, the right of the people,
while in service of the Militia to keep and bear Arms, shall not be infringed"
or simply
"A well-regulated Militia, being necessary for the security of a free State must be established."
These were not how the document written.
Certainly, these Men of such education would have seen that any of the above would have much better accomplish their intent. But for some reason, they didn't, PLUS
Included it in a position within the document that makes almost zero sense if it had been include as you say it is.