Melkor was formed from the thoughts of Eru by the thoughts of Eru. Was the possibility of his evil already in Eru's thoughts? Was Melkor a 'wild-card'? Was he deliberate? What was Eru's reason for allowing it?
Who knows. Why does every fantasy story and religion need good and evil, good guys vs bad guys? Because otherwise it wouldn't make much of a story, i guess.
I think the definition of good is "accepting what the Valar or whatever deities created, and live together in harmony within that creation, with its creatures". The definition of evil would be "not accepting what whatever deities created, and because of that wanting to destroy or undo that creation, and rebuild it by your own plans". That's what Melkor had in mind : Melkor wanted to make a world on his own, a world completely according to his vision, without help from the other Valar, and rule like a King among its inhabitants forever. To me, evil is clearly not "slaying our beloved Hobbits, Elves and Men" because our beloved Elves and Men equally slay Orcs, Goblins, Balrogs and what not. To those so-called "evil" races, like Orcs, it are the Elves and Men who are evil. Whoever is considered 'evil' in a book, is the defeated one, as history is written by the victor.
Then Eru disrupted his plans, the music stirred by Melkor, by correcting his music and the other Valar then followed Eru's music. But Melkor still didn't accept this and then, from the very moment he entered Arda, til the moment he was pushed into the Void, the tried to undo the creations of his siblings. The inhabitants of Arda therefore call him "evil". We call that "evil". Because Morgoth lost, he got pushed into the Void.
I don't think Eru intended on Melkor becoming Morgoth, or become the adversary of the other 12 Valar who descended to Arda, the only thing he intended is that he made Melkor the most powerful of the Ainur, together with Manwe. Perhaps Melkor had the power to create his own Arda by himself. Eru clearly didn't intend on Melkor disrupting the music, otherwise he wouldn't have become so angry before correcting the music for the final time.
Well, we all should thank Melkor, as without the lad we wouldn't have much of a story. As in, no story at all. Just all happy Elves and Men, dancing around campfires forever.