Margaret was not Scottish by birth. She was the daughter of Princess Agatha of Hungary and the Anglo-Saxon Prince Edward Atheling. She spent much of her youth in the court of her great-uncle, the English king, Edward the Confessor. Her family fled from William the Conqueror and was shipwrecked off the coast of Scotland. King Malcolm befriended them and was captivated by the beautiful, gracious Margaret. They were married at the castle of Dunfermline in 1070.
Malcolm was good-hearted, but rough and uncultured, as was his country. Because of Malcolms love for Margaret, she was able to soften his temper, polish his manners and help him become a virtuous king. He left all domestic affairs to her and often consulted her in state matters.
Margaret tried to improve her adopted country by promoting the arts and education. For religious reform, she instigated synods and was present for the discussions which tried to correct religious abuses common among priests and others, such as simony, usury and incestuous marriages. With her husband, she founded several churches.
Margaret was not only a queen, but a mother. She and Malcolm had six sons and two daughters. Margaret personally supervised their religious instruction and their other studies.
Although she was very much caught up in the affairs of the household and country, she remained detached from the world. Her private life was austere. She had certain times for prayer and reading Scripture. She ate sparingly and slept little in order to have time for devotions. She and Malcolm kept two Lents, one before Easter and one before Christmas. During these times she always rose at midnight for Mass. On the way home she would wash the feet of six poor persons and give them alms. She was always surrounded by beggars in public and never refused them. It is recorded that she never sat down to eat without first feeding nine orphans and 24 adults.
In 1093, King William Rufus made a surprise attack on Alnwick castle. King Malcolm and his oldest son, Edward, were killed. Margaret, already on her deathbed, died four days after her husband.