Eirik was the eldest surviving son of King Magnus the Lawmender of Norway, and his wife Ingeborg Eriksdatter, daughter of King Eric IV of Denmark. In 1273, when he was 5 years old, he was given the title of king, alongside his father, who planned to hold a coronation for Eirik as his subordinate co-ruler in the summer of 1280. However, King Magnus died before this could be arranged, and Eirik became sole king and was crowned as such in Bergen in the summer of 1280. During his minority, the kingdom was ruled by a royal council consisting of prominent barons and probably also his mother, the dowager queen Ingeborg. After Eirik came of age in 1282, this royal council is still thought to have had a major influence over his reign. His brother, Haakon, was in 1273 given the title "Duke of Norway", and from 1280 ruled a large area around Oslo in Eastern Norway and Stavanger in the southwest, subordinate to King Eirik. The king's main residence was in Bergen in Western Norway.
Eirik married princess Margaret of Scotland, daughter of King Alexander III of Scotland in Bergen in 1281. Margaret died two years later in childbirth, giving birth to Margaret, Maid of Norway, who became queen of Scotland in 1286 until her death in 1290. Her death sparked the disputed succession which led to the Wars of Scottish Independence. Eirik briefly and unsuccessfully laid claim to the Scottish crown as inheritance from his daughter.
Eirik later married Isabel Bruce, sister of King Robert I of Scotland. Their marriage did not produce a surviving male heir, though it did produce a daughter, Ingeborg Eriksdottir of Norway, who married Valdemar Magnusson of Sweden, Duke of Finland, in 1312. Ingeborg Eriksdotter was styled Duchess of Öland (wikipedia)