There are a number of theories, a lot of debate, and a lot of musty history books. As a *very* brief overview, here is part of an essay by Henry C. Clausen, a noted Masonic author. This is, of course, just one point of view-- many other theories exist, but Cluasen nicely covers the basics:
"Our Masonic antiquity is demonstrated by a so-called Regius Manuscript written around the year 1390, when King Richard II reigned in England, a century before Columbus. It was part of the King's Library that George II presented to the British Museum in 1757. Rediscovered by James O. Halliwell, a non-Mason, and rebound in its present form in 1838, it consists of 794 lines of rhymed English verse and claims there was an introduction of Masonry into England during the reign of Athelstan, who ascended the throne in A.D. 925. It sets forth regulations for the Society, fifteen articles and fifteen points and rules of behavior at church, teaching duties to God and Church and Country, and inculcating brotherhood. While the real roots of Masonry are lost in faraway mists, these items show that our recorded history goes back well over 600 years. Further proof is furnished through English statutes as, for example, one of 1350 (25 Edward III, Cap. III) which regulated wages of a "Master...Mason at 4 pence per day." The Fabric Role of the 12th century Exeter Cathedral referred to "Freemasons."
The historical advance of science also treats of our operative ancient brethren who were architects and stonemasons of geometry. It is apparent from this portrayal that they had a very real and personal identification with the Deity and that this fervent devotion provided energy to build cathedrals. They embraced the teachings of Plato and understood and applied Pythagorean relationships. Just as there is a beauty of harmony credited to mathematical relationships on which music is based, in precisely the same way these master geometricians treated architecture. The architects and stonemasons became the personification of geometry, performing extraordinary feats with squares and compasses. Geometrical proportion, not measurement, was the rule. Their marks as stonemasons were derived from geometric constructions. The mighty works they wrought, cathedrals with Gothic spires pointing toward the heavens, and especially their "association," were not without danger and opposition, bearing in mind the Inquisition established in 1229, the Saint Bartholomew's Eve Massacre of 1572, and the revocation of the Edict of Nantes in 1685. These historical points remind us of the need for our cautions against cowans and eavesdroppers.
Our operative Brethren of the Middle Ages thus were the builders of mighty cathedrals throughout the British Isles and continental Europe, many of which still stand. These skilled craftsmen wrote in enduring stone impressive stories of achievement, frequently chiseled with symbolic markings. With these architectural structures of these master builders there was a companion moral code. These grew up together. Out of this background modern Freemasonry was born.
Although "Lodges" had existed for centuries, four of the "old" Lodges met in London on St. John the Baptist's Day, June 24, 1717, and formed the first Grand Lodge of England, thereafter known as the Premier Grand Lodge of the world. No longer operative as of old, the Masons carried on the traditions and used the tools of the craft as emblems to symbolize principles of conduct in a continued effort to build a better world.
The American colonial Masonic organizations stemmed from this Grand Lodge of England and were formed soon after 1717. Its then Grand Master appointed Colonel Daniel Coxe as Provincial Grand Master of New York, New Jersy and Pennsylvania on June 5, 1730, and Henry Price of Boston as Provincial Grand Master of New England in April 1733." -- Henry C. Clausen.