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 1 challenge, from Crinan, earl of Atholl and Duncan's father, who sought to place his second don, Maldred on the throne. The two sides met at Dunkeld in 1045CE,a dn 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 cclaim 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 continute the campaign. Macebth 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.