This question already has an answer here:
- Did Ilúvatar anticipate Melkor? 3 answers
Did Tolkien write anything about the theodicy implied in the great music and later events?
Iluvatar (if i recall correctly) had perfect knowledge of every moment of his music and universe. The all-father knew exactly what was going to happen when he created Melkor. So why did he do it knowing the horrors Melkor would cause?
Tolkien was a scholar and devout Catholic in a university. He had access to theologians, philosophers and texts discussing the source of evil from the past 1000 years or so. I would expect him write something about the source of evil in his world.
I have a spin off question for bonus points: Did any characters ask about the necessity of evil, in-universe? (My copy of the Silmarilion is packed away, otherwise I'd just re-read it)