I think that the tragedy of Melkor's Evil ended up producing a greater beauty and Good than Evil had ever imagined. Of course, this is an aspect of Christian (Catholic) theology that Tolkien inserted into the Legendarium:
* Death as punishment and gift of Eru to men. For mankind will have a privilege that not even the elves will have: to stand by God's side after they leave Arda, whether in joy or sorrow;
* Life and death are the Yin and Yang of cycles of creation, destruction and renewal. This prevents the stagnation of life. Can you imagine if everything was perfect and harmonic? I imagine that everything would be tedious and stagnant.
* The arrival of Eru himself to heal the wounds of Evil in the world: Finrod and Andreth's dialogue (in the History of Middle Earth) says that Ilúvatar will enter his work to save his children. Obviously, this is a reference to Jesus Christ. But I think that the Silmarillion itself references an even greater beauty (than the Ainur, than that of the Elves) would come to Arda and "and evil yet be good to have been.’:
he raised his head, as one that hears a voice far off, and he said: ‘So shall it be! Dear-bought those songs shall be accounted, and yet shall be well-bought. For the price could be no other. Thus even as Eru spoke to us shall beauty not before conceived be brought into Eä, and evil yet be good to have been.’
This beauty "not before conceived be brought into Eä" is, IMHO, a reference to Jesus Christ.
The Catholic idea of felix culpa cited in the Exultet at the beginning of the Easter Vigil, the night before Easter, which proclaims in part,
O certe necessárium Adæ peccátum, quod Christi morte delétum est! O felix culpa, quæ talem ac tantum méruit habére Redemptórem!
usually translated as
O truly necessary sin of Adam, destroyed completely by the Death of Christ! O happy fault that earned for us so great, so glorious a Redeemer!
Fr Jonah Pollack, a Dominican Friar in New York, explain the concept of "Felix Culpa":
The sin of Adam was necessary so that it could be destroyed by the death of Christ. Adam’s fault is happy because it necessitated Christ’s redemption. The sin of Adam is greeted with jubilation because it created the problem to which Christ’s redeeming death and resurrection is the solution. It brought on the disease for which Easter is the cure. To be sure, the sin of Adam is not itself good. It is not, in itself, a cause for rejoicing. It is, rather, an occasion for good. It is the tragic plot twist that sets the stage for the story’s glorious resolution. Our rejoicing is therefore is not that Adam sinned, but that, out of Adam’s sin, God brought about a greater good.
[https://opeast.org/2016/03/o-happy-fault/\](https://opeast.org/2016/03/o-happy-fault/)
Even Saint Augustine said that:
God judged it better to bring good out of evil than not to permit any evil to exist.
This concept is intimately intertwined with the Problem of Evil, which arises from Free Will:
And thou, Melkor, shalt see that no theme may be played that hath not its uttermost source in me, nor can any alter the music in my despite. For he that attempteth this shall prove but mine instrument in the devising of things more wonderful, which he himself hath not imagined. And thou, Melkor, wilt discover all the secret thoughts of thy mind, and wilt perceive that they are but a part of the whole and tributary to its glory.
This does not justify or excuse evil in any way, nor is Eru in any way responsible for their evil actions; only that in the ultimate end, Eru’s designs may not be opposed, and he will overcome all evils of his fallen creatures to achieve good beyond the measure of their wickedness.