When Eru Iluvatar brought forth his own thoughts in the Ainur, the most powerful and dangerous of these was Melkor. In him burned that deep and dangerous part of the mind from whence some of the most startling of ideas can come -- inspiration, imagination, cunning. The other Ainur he brought to bring form to those ideas, and temper them with the calmer ideas of their own -- wisdom, careful thought, compassion. The Ainur needed no spoken words to communicate, as one thought hears another. Thought knows each other. Eru knew that Melkor would take claim for his own victories and accomplishments, even as he knew that the other Ainur must shun him publicly because of their nature. But he knew that they all depended on the other for the total harmony. Melkor provided the discord and the counterpoint to the sweet melody floating above it. The Ainur who were unsure filled in the harmony between, layering the music further.
In each of the Ainur was Eru's love of creativity, and they each sought to bring forth their own mark to his world. As Melkor's fires transformed Ulmo's waters into countless intricacies of potential, Manwe's winds fanned and fueled Melkor's flames.
In the end it was Melkor's own innovation that bested him -- the children of Iluvatar used ideas yet unfathomed to win the war against Sauron, his servant. That same unpredictability which had let Melkor slip time and again through the grasp of the Ainur, at last let small Frodo and Sam save their earth.
In the time after time, when Iluvatar gathered the Ainur -- both Valar and Maiar -- to him, and Melkor freely sang with the others he finally understood all of that plan.