Possibly the first use of "well-regulated militia"Scots MP Andrew Fletcher of Saltoun used the phrase “well-regulated militia” in his 1698 pamphlet, "A Discourse Of Government With Relation To Militias". By this he meant a universal draft.
In the ''Discourse'' Fletcher strikes a number of notes that were to echo through the US constitution. Fletcher wrote of the oppressive potential of standing armies and argued against the hiring of mercenaries, recommending instead reliance on “a well regulated militia” . He wrote of the need for baronial control of the militia to check unjust royal power, and in this we may see an origin of the division of state and federal authority over the militia.
To the objection that the typical citizen was a poor soldier, Fletcher replied that they made up an “ordinary and ill-regulated militia.” He then set out his idea of a well-regulated militia:
What I would offer is, that four camps be formed, one in Scotland, and three in England; into which all the young men of the respective countries should enter, on the first day of the two and twentieth year of their age; and remain there the space of two years, if they be of fortunes sufficient to maintain themselves; but if they are not, then to remain a year only, at the expense of the public.He goes on to praise the martial virtues such training would instill (he had after all himself been a soldier) and adds that all male citizens should continue to drill four hours a week.
The relevance of Scottish militia history to the USAIt's a pretty amazing history. The right of the Scots to participate in the militia was lost in the Acts of Union, which unified the parliaments of Scotland and England. The Scottish Militia Bill of 1707, which would have restored the Scots right to participate in the militia, was vetoed by Queen Anne, in the last royal veto in British history. Thereafter, the Jacobite Risings of 1715 and 1746 persuaded Parliament to pass the 1716 Disarming Act and then the 1746 Act of Proscription, which intensified penalties and even forbade the wearing of "highland dress" .
The relevance to the USA is set out by Konig . It comes through Fletcher and James Burgh, who was quoted by Franklin and who corresponded with John Adams. To sum up a fairly complex history, the suppression of the Scottish militias and weapons ownership influenced the writing of the Second Amendment, and the phrase "well-regulated militia" is a direct reference to that history.
A few final thoughtsAs I went through my very light overview of the history, some things became clear. First, the phrase "well-regulated militia" is a direct quote of the Scottish authors Fletcher and Burgh, and probably others. The Framers were referencing those ideas when they included it. (And, yes, that means that Heller was wrongly decided. Justice Scalia, I do not miss you.)
Second, the nature of the militia obligation and the militia gets narrowed by succeeding authors and legislators. From Fletcher's universal draft of men, the service requirement was reduced by Burgh to to a draft of "all men of property." Hamilton, in Federalist Paper 29, reduced the training requirement still further. Once the US militia was a going thing, militia service turned from a much-demanded right into an onerous, expensive, and resented obligation, and in the 1830s and 1840s the states exempted most men from it.
Third, what I suppose one might call the British theory of the militia was built around the weapons technology its day. The whole idea of an individual right to go armed was, first, taken for granted, and second, not taken seriously. One man with a musket, or more likely two pistols, could be a robber, but it took numbers and organization to make a revolution. With the invention of the modern rifle, we achieved such a level of lethality that a single individual with a good rifle can be as lethal as a whole team of cannoneers and with a cannon in the old days. I can't see that any of the Scots and English militia theorists would have advocated widespread distribution and carrying of such lethal weapons without at least some restrictions on who could carry them routinely.
 Ironically, Fletcher had himself been a mercenary in Hungary. See http://www.johngraycentre.org/people/movers_shaker/andrew-fletcher-of-saltoun-the-patriot-1655-1716
 Which sounds very odd, but consider the suppression of gang colors in US schools.
 Konig, David Thomas (Spring 2004). "The Second Amendment: A Missing Transatlantic Context for the Historical Meaning of 'the Right of the People to Keep and Bear Arms'". Law and History Review (American Society for Legal History, Inc.) 22 (1): 120–159. doi:10.2307/4141667.