In the play, Macbeth changes from a loyal vassal of the previous king to a murderous tyrant - the real life 11th century Macbeth was not such a horrible person and reportably had a greater claim to the throne than the "good guys" in the play.
Macbeth was son of Findlaech, the Earl of Moray, and of Donada, daughter of Malcolm II. He came to the throne as a result of a disaterous campaign by Ducan I against Thorfinn of Orkney, with whom Macbeth had allied himself. The alliance kept peace between Scotland and the Norse, and Macbeth was able to build a strong kingdom, meeting only one challenge, from Crinan, Earl of Atholl and Duncan's father, who sought to place his second son, Maldred on the throne. The two sides met at Dunkeld in 1045CE, and Crinan and Maldred ended losing the battle and their lives.
In 1054 Duncan's son Malcolm, who had been in England the while, raised his own claim to the throne, supported by Edward the Confessor and Siward of Northumbria. The battle of Dunsinance resulted in a pyrhhic victory for Malcolm, whose losses were too great to continue the campaign. Macbeth ruled on for three or four years of civil war, until killed in an ambush. Even then he had revenge on Malcolm, for it was Macbeth's stepson Lulach who succeeded him, not the English candidate.