After the Battle of Stiklestad and Olaf's death, Olaf's brother Harald Hardrada went to Kiev to report the news. Magnus stayed in Kiev, learning Russian, Greek, and martial arts (although his age was still in single digits). Unhappiness in Norway with Cnut's first wife as his regent meant the Norwegians were eager for alternatives. Two men traveled to Yaroslav's court and brought Magnus back.
Astrid gave her approval of the plan to put Magnus on the throne, and became one of his strongest supporters. Her brother was the current king of Sweden, and he also supported Magnus. Magnus was proclaimed king in 1035. He was 11.
King Harthacnut of England and Denmark (Cnut's son and successor) was interested in repairing relations between Norway and Denmark. Magnus, on the other hand, had his father's desire to conquer and rule Denmark. The nobles of the countries did not want another war, and brought the two kings together for negotiations. It was agreed that each would be the other's successor: the survivor would be king of three countries.
In 1042, Harthacnut died. Sweyn Estridsen, Cnut's nephew, had been left by Harthacnut in charge of Denmark and thought he should be king. He fled and returned in 1043 with an invasion of Wends (Slavs from northern Germany). A battle ensued in which Magnus wielded Hel, his father's battle-axe. It is recorded that over 15,000 were killed and the Wends defeated. The Heimskringla recorded that Sweyn was made Earl of Denmark under Magnus to keep him happy (and close enough to keep an eye on).
Magnus would have liked to re-create Cnut's North Sea Empire, but Sweyn was not the only opposition to be dealt with. I'll tell you how that for Magnus went the next time.