I am not sure why He created evil but He created everything.
Maybe we need evil so we can appreciate goodness. Just as we need darkness to appreciate light. Or hate to appreciate love.
Many believe the first sin occurred when Adam and Eve ate from the Tree of Knowledge, but they are incorrect. The first sin occurred in Heaven. It caused Satan and a third of the angels to be driven out of Heaven to earth. Without that (sin of pride) occurring, Satan would not have existed to tempt Eve.
If there was no suffering, pain, or death in the world, would man appreciate God and obey Him....obviously not...as that was what Adam and Eve had, and they squandered it within a few days of creation.
I wonder if God created evil so we could find Him. It makes the most sense to me. For He is goodness; but man needs to understand and experience evil to find the way to Him.