Melkor was the name of Morgoth before he rebelled against Iluvatar, much like Satan was Lucifer before he rebelled against God. Also much like Lucifer, Melkor was at the top of the heavenly hierarchy, given greater knowledge and power by Iluvatar than the other Valar (who were the highest of the Ainur, the heavenly beings. Valar were above the Maiar, who were also Ainur. Wizards were of the Maiar.)
But I digress.
As Iluvatar and the other Ainur sang Ea (Ea comprised the heavenlies and Arda, aka, Middle-earth) into existance, Melkor decided to sing his own songs, creating some of the more unpleasant things in Arda. He also had a following among the Maiar, the most loyal of these being Sauron, his head servant.
When Arda's creation was basically completed, some of the Ainur descended there to live and expand the creation. Melkor was one of them, but spent most of his time marring and distorting the creations of his heavenly brethren.