Answer:
The Kalmar Union was a personal union of Denmark; Sweden, which included Finland; and Norway, with its dependencies of Iceland, Greenland, the Faroe Islands, the Orkney Islands, and the Shetland Islands. It was brought about by a quite remarkable woman who was the regents of these countries, now known as Queen Margaret I of Denmark.
Margaret was the daughter of a king of Denmark, and was married to a King of Norway. When her father died, in 1376, she was not legally allowed to rule, because she was a woman, but she managed to have her son Olav declared the heir to the throne, and herself declared regent. Not long after, in 1380, her husband died, and Olav, now King Oluf of Denmark, became king of Norway, also under her regency. Olav died in 1387, and she managed to have the nobles, who at this point had learned she was a competent ruler, declare her nephew, Eric of Pomerania, heir to both kingdoms, again under her regency.
Meanwhile, there was a dispute going on in Sweden, to which Eric had some claim, between the local nobility and the king, Albert of Mecklenburg. The Swedes were unhappy with the control the Hanseatic League was gaining in Sweden, especially as they regarded it as a German organization, and Albert was also German, so they rejected him as well. They elected Margaret as regent of Sweden, and subsequently a combined army of Danes and Swedes defeated Albert's army.
In 1397, a treaty was signed by the representatives of Denmark, Norway, and Sweden at the castle of Kalmar. Under the terms of the treaty, all three kingdoms would have the same monarch, but their governments would continue to be independent. This treaty was not legally binding on any of the three kingdoms, because none of the assemblies required to ratify it did so. Nevertheless, the treaty endured de facto until 1523. Interestingly, Margaret remained as regent until she died in 1412, having been King Eric's regent for 23 years.