“A well regulated militia being necessary to the security of a free State, the right of the People to keep and bear arms shall not be infringed.””
See that comma after free state, now read the second part of the sentence. Don’t have to be a lawyer, just need to be an English teacher.
To some extent, the use of commas is an art rather than a science a matter of the writers personal style and intended meaning.
However, following these three patterns of comma usage will help make your sentences clear:
Use commas to separate items in a series.
Use a comma in a compound sentence before the coordinating conjunction (and, but, or, for, yet, so) that joins the two independent clauses (complete sentences).
Use a comma to set off nonessential elements that precede, interrupt, or follow the independent clause.