Donald III (a.k.a. Domnall mac Donnchada) lived from 1033 to 1099 and was King of Scotland from 1093 to 1094 and 1094 to 1097. He was the brother of his predecessor, Malcom III and, like him, son of Duncan I. The wider picture in Scotland at the time is set out in our Historical Timeline.
Edmund was the second son of Malcolm III and Margaret, and the oldest surviving from his father's second marriage at the time of Malcolm's death. He seems to have shared the throne with Donald III during both periods of rule. If Scotland had been fully committed to the principle of primogeniture at the time of the death of Malcolm III, his successor should have been Duncan II of Scotland, Malcolm's first son by his first marriage.
But Malcolm's brother Donald saw things differently. He didn't approve of the anglicisation of the court and of Scotland more widely, of the supression of the Gaelic language in public life: and he had a vested interest in resurrecting the old process of tansitry, by which succession could be distributed more widely.
The only surprising thing is that he was supported in this by Edmund, the oldest surviving son from Malcolm III's second marriage, to Margaret. Maybe Edmund simply saw Donald as his only possible chance of power. The two effectively split Scotland between them, with Donald ruling the north of the country and Edmund the south.
Early in 1094 the two were successfully challenged for the crown by Duncan II, who arrived in Scotland with an Anglo-Norman army. However, within six months Duncan's supporting troops withdrew, and his assassination led to the restoration of the joint rule of Donald III and Edmund. In 1097 Edgar, the fourth son of Malcolm III and Margaret came north into Scotland with an army and considerable support from William II of England. Donald III and Edmund were deposed and replaced on the throne of Scotland by Edgar.
Donald was blinded and remained a prisoner at Rescobie, Angus until he died in about 1100. Edmund was treated less harshly than Donald by his brother, who allowed him to become a monk at Montacute Abbey in Somerset, where he lived out his days.