Evil wouldn’t even be possible if not for the existence of good. God is good, and He gives us free will because He wants a real relationship with us. Otherwise, we would be mindless robots. But because we have free will, we can make decisions by which evil can enter the world and propagate itself.
If God made us such that we didn’t even have the option of doing wrong, we wouldn’t have free will, and God doesn’t want that because He loves us.