“We didn’t sit down and say, okay now bring on the bad guys. The heroes are the focus and the drivers. We choose those villains because of what you hope they will bring out in the hero. Malekith and the dark elves give Thor a noble foe, tap into Asgardian history, and bring about somebody who is worse than Loki, to put Thor in a position where he had to ask for his brother’s help.” - Marvel Studios President Kevin Feige
And from Marvel's wiki on Malekith:
Malekith the Accursed ruled the Dark Elves of Svartalfheim. Svartalfheim is one of the nine worlds of Asgard. Malekith mastered sorcery, making him a formidable ally to the other enemies of Asgard. He formed an alliance with the god of mischief Loki on behalf of Surtur. Not long after that agreement, he used a special food provided to him by Hela. The food contained some sort of magic, which gave him control of the humans of Earth. While continuing his quest, he took the life of Eric Willis, guardian of the Casket of Ancient Winters. Before his death Willis conveyed the Casket's location to Loki. Not willing to give up his quest, Malekith Kidnapped the Asgardian Lorelei in order to gain control of the god of Thunder. Thor discovered that he had been tricked into falling for a stack of wood, and became enraged as he learned that the real Lorelei was being held captive by Malekith. Lorelei was eventually freed but, Thor was forced to battle Algrim the Strong. Malekith attempted to destroy both combatants by plunging them into a pit of molten magma; subsequently Malekith retrieved the Casket of Ancient Winters, from the being known as Jagrfelm. Shortly after Jagrfelm's death, Malekith released its power upon Asgard in his quest to rule all nine worlds.