Margaret was the eldest child of Alexander III, king of Scotland (September 1241 - March 1286) and Margaret of England (September 1240 - February 1275), daughter of Henry III and Eleanor of Provence and sister of Edward I. Alexander and Margaret (who was probably named after her aunt Marguerite of Provence, queen of France) married in York on 26 December 1251, when he was ten and she eleven; he had succeeded his father Alexander II in July 1249, and his kingdom was being ruled by a squabbling group of regents during his minority. The Lanercost chronicler calls Margaret of England, queen of Scotland, "a woman of great beauty, chastity, and humility."  Henry III and Queen Eleanor, a couple I otherwise find it very hard to warm to, were, for all their numerous faults, devoted parents: on learning that Margaret was deeply miserable, kept apart from her youthful husband and little more than a prisoner of Alexander's regents, they themselves rode up to Edinburgh to set matters to rights. Her natal family, which also included her younger siblings Beatrice and Edmund, appears to have been devoted to each other and to have spent as much time together as possible, and at some point Margaret received a "cup of gold with feet" from her brother Edward I, which was apparently returned to him after her death, as it appears in his Wardrobe account of 1276/77. 
Alexander III and Queen Margaret visited England in the autumn of 1260; Margaret was met at St Albans by her fifteen-year-old brother Edmund (who eighteen or so years later became the father of Thomas of Lancaster), and was reunited not only with her parents but with her uncle Richard of Cornwall, king of Germany, and his second wife, Eleanor of Provence's sister Sanchia. (The Flores Historiarum waxes lyrical about this meeting of three kings and three queens.)  Margaret discovered during the trip that she was several months pregnant, and asked her husband for permission to stay in England with her parents until after she gave birth. Alexander agreed, but, understandably reluctant to leave his newborn child, possibly the future king of Scotland, under the control of the king of England - father-in-law or no - requested on 30 September 1260 that Henry III make the following oath:
"Should the mother [Queen Margaret] die, he promises to return the child, and should the child die, to let the mother return freely. Should the king its father die, or other unforeseen event occur to him, the king [Henry] promises that the bishops of St Andrews, Aberdeen, Dunblane and Whithorn, the earls of Fife, Buchan, Strathearn, Dunbar and Mar, and John Comyn, Alexander the Steward of Scotland, Alan Doorward and Hugh Abernethy, barons, or any four or three of them, shall receive and take the child to Scotland, the state of neither country being taken into consideration." 
And so Margaret of Scotland was born at Windsor Castle on 28 February 1261, her mother then twenty and her father, who had returned to his kingdom the previous November, nineteen. Henry III had promised to return Queen Margaret and her child to Scotland by Easter Sunday, 24 April 1261, but in the end - perhaps because of complications or an illness after childbirth or the young queen's reluctance to leave her parents and her homeland - they remained in England until the end of May. Margaret of Scotland was probably the eldest of Henry III and Eleanor of Provence's grandchildren (precisely when Edward I and Eleanor of Castile's first child was born is unclear, though they certainly had a daughter by 1264). Inevitably, little is known of her childhood. Her brother, named after their father and the heir to the Scottish throne, was born on 21 January 1264, and after a very long gap, another brother, David, was born on 20 March 1273, four months after the death of their grandfather Henry III. The two elder children met their uncles Edward and Edmund in the summer of 1267, when the young men visited Scotland; this was Longshanks' first visit to that country, though most definitely not his last, as decades later he was to turn his late brother-in-law's kingdom into a war zone. Marion Campbell says "There was no protocol for English state visits to Scotland - most such visitations had not been of a social nature - and Edward and Edmund came informally." 
Margaret of Scotland lost her mother just before her fourteenth birthday: Margaret of England, queen of Scotland, died on 26 February 1275 at the age of only thirty-four. By unhappy coincidence, her younger sister Beatrice, wife of the duke of Brittany's heir, also died less than a month later, to the grief of their mother Eleanor of Provence. The Lanercost chronicler, who although frequently a useful source for Scottish events was unfortunately also prone to writing rubbish on occasion, wrote "Richard of Inverkeithing, bishop of Dunkeld, departed from the world, treacherously poisoned, and it is believed by many that the aforesaid queen [Margaret] perished in the same manner."  Although the cause of Margaret's death is unknown, there is absolutely no reason to give credence to this allegation. King Alexander III remained a widower for the next decade, which would prove with hindsight to have been a most unwise decision.
King Magnus VI of Norway, whose father Haakon IV Alexander III had defeated at the battle of Largs in 1263, died on 9 May 1280, and within weeks Alexander had opened negotiations for Magnus's grandson and heir Erik II to marry Margaret. Erik was born sometime in 1268, so was at least seven years younger than Margaret and at the time of the wedding negotiations only eleven or twelve to her nineteen; despite his striking nickname of 'Priest-Hater', he seems to have grown up to be a rather mild and ineffectual young man. Here's how the Lanercost chronicle reports the negotiations: "At this time the king of Norway died, leaving as successor his son called Magnus [sic]; who hearing that the king of Scotland had an amiable, beautiful and attractive daughter, a virgin, of suitable age for himself (being a handsome youth of about eighteen [sic] years) could not rest until a formal mission, divines as well as nobles, had been sent twice to obtain her as his spouse and consort on the throne."  Margaret's feelings about marrying a boy a few years her junior are a matter for speculation, though she did send a letter (in French) to her "very dear uncle" Edward I sometime in 1280 - whether before or after the marriage negotiations is hard to say, as she didn't date the letter - telling him that she was "healthy and cheerful" (saine et haite) by God's mercy. She ended by wishing Edward "a thousand greetings," mile saluz, and requested that he constantly inform her of his own health and his wishes towards her. 
The wedding negotiations were completed on 25 July 1281, and Margaret sailed from Leith on 11 August with a huge dowry of 14,000 marks, arriving in Bergen on 15 August; among those accompanying her were the earl and countess of Menteith and the abbot of Balmerino. She was greeted in her new land with "demonstrations of great joy." Her wedding to thirteen-year-old Erik, and her coronation as queen of Norway, both took place at the Mariakirken in Bergen on 31 August; a wedding hymn in Latin has fortuitously survived, the first stanza of which Marion Campbell translates as: "From you has risen, o gentle Scotland, a light which gleaming Norway truly acknowledges, at whose transit you sigh deeply because your king's daughter is taken from you." Little can be said about Margaret's rather brief tenure as queen of Norway, though she appears to have been very popular, and was said in her new country to be "she who made our king a man."  She became pregnant in the summer of 1282; one might speculate that Erik's fourteenth birthday, at which age he would have been considered old enough to consummate his marriage, had recently passed.
Tragedy struck in early 1283: Margaret of Scotland, queen of Norway, died on 9 April (or 28 February, her birthday, according to Lanercost), aged twenty-two, shortly after giving birth to a daughter. King Erik II was now a father and a widower at the age of only fourteen or fifteen. Their daughter was named Margaret after Margaret herself and her mother the queen of Scotland - Erik's daughter by his second wife, Robert Bruce's sister Isabel, was named Ingiborg after his own mother - and is known to history as the Maid of Norway. The Lanercost chronicler, who for some reason really had it in for poor Alexander III - who has always struck me as a very pleasant and likeable man, as well as a strong and excellent king - blames Margaret's death on her father and says that it came about "in order that God's long-suffering should by many afflictions soften to a proper degree of penitence the heart of the father through whose wrong-doing these things came to pass." He also blames the early deaths of Alexander's queen and his sons on Alexander's "sin."  Strange.
Further tragedy struck Alexander III, and Scotland, in January 1284, when his elder son Alexander died a few days after his twentieth birthday (the king's younger son David had died aged only eight in 1281). Young Alexander was married to yet another Margaret, one of the many daughters of Guy de Dampierre, count of Flanders, but left no children. (Guy's daughter Philippa was betrothed to the future Edward II some years later, with her sister Isabella as 'back-up'.) Edward I granted Margaret, called the widow of 'Monseignur Alexandre', a safe-conduct to return through England to Flanders on an unspecified date, at the request of her father Count Guy.  According to Lanercost, young Alexander prophesied shortly before he died that "My uncle [Edward I] shall fight three battles; twice he will conquer; in the third he will be overthrown."  I bet lots of people, then and now, wish that prophecy had come true.
This left Queen Margaret of Norway's baby daughter Margaret the Maid of Norway as sole heir to her grandfather, as Alexander III acknowledged in a letter to his brother-in-law Edward I on 20 April 1284, five days before the birth of Edward II in Caernarfon: "though death has carried off all of his [Alexander's] blood in Scotland, one yet remains, the child of his own dearest daughter the king's [Edward's] niece, the late queen of Norway, now under divine providence the heir apparent of Scotland." All thirteen Scottish earls and countless barons including the Bruces, Balliols and Comyns, however reluctantly, acknowledged the Maid as heir apparent to the Scottish throne at a meeting held in Scone on 5 February 1284: "...we shall all receive our illustrious child Margaret, daughter of the daughter of our said lord king, Margaret of good memory, sometime queen of Norway, by the illustrious Lord Erik king of Norway; and as she descends with full legitimacy we shall receive her as our lady and right heir of our said lord king..." 
To have a baby foreigner, female to boot, as sole heir to the throne was hardly a desirable situation, and Alexander III married for a second time in October 1285, a French noblewoman named Yolande or Joleta de Dreux - his mother Marie de Coucy, second queen of Alexander II, was also French - in order to sire more children. He was riding to see Queen Yolande on 19 March 1286 during a terrible storm, when his horse fell off a cliff and he died of a broken neck. Alexander was still only forty-four, a vigorous and extremely able man in the prime of life, and his early death was to have disastrous consequences for Scotland. His little granddaughter died at the age of seven on her way to her kingdom and marriage to the future Edward II in the autumn of 1290; three centuries of conflict and bloodshed between Scotland and England were to be the tragic result.
1) The Chronicle of Lanercost 1272-1346, ed. Herbert Maxwell, p. 9.
2) Calendar of Documents Relating to Scotland 1272-1307, p. 21.
3) Flores Historiarum, ed. H.R, Luard, vol. II, pp. 459-460.
4) Marion Campbell, Alexander III, King of Scots, p. 122.
5) Campbell, Alexander III, p. 172.
6) Lanercost, pp. 9-10.
7) Ibid., p. 21.
8) Cal Docs Scot, p. 60.
9) Campbell, Alexander III, pp. 214-216, for the wedding hymn, quotation and Margaret's dowry and journey.
10) Lanercost, pp. 9, 32.
11) Cal Docs Scot, p. 73.
12) Lanercost, p. 32.
13) Cal Docs Scot, p. 73; Campbell, Alexander III, pp. 219-221.