The reason there is evil in the world is so that the choice of doing good is meaningful. If a person were not given the opportunity to do bad, and decline it and do something good instead, then that good is forced, to some degree. Either way, the reward for doing that good is lessened, and this is against Hashem's will. So in order that man should truly become the owner and master of his own good, Hashem made in him a pull towards both evil and good (see Derech Hashem 1:3:1).
This is really a pull towards the physical vs a pull towards the spiritual, as Ramchal writes (ibid 1:2:3):
And behold that any true perfection is surely His existence, may He be
blessed; and any deficiency is only the absence of His goodness, may
He be blessed, and the hiding of His face. So it comes out that the
shining of His face, may He be blessed, and His closeness are the root
and the cause of all perfection that will be; and the hiding of His
face is the root and the cause of all the deficiency - such that
according to the measure of the hiding, is the measure of the
deficiency that results from it. Therefore when this creature - that
stands evenly between the perfections and the deficiencies that are
outgrowths of the shining and the hiding - strengthens itself with
perfections and acquires them for itself on its own; behold, it
attaches [itself] to Him, may He be blessed, who is their root and
their source. And according to that which it increases perfection, so
does it increase in attachment to Him; until when it reaches the end
of the acquisition of perfection, behold it reaches the end of
attachment and cleaving to Him, may He be blessed. So it benefits from
His good and perfects itself in Him and becomes, itself, the owner of
its good and its perfection.
This equal pull towards both directions was changed greatly when Adam and Eve ate the fruit. Before, they just had a distracting pull towards the material, which is the natural state for a living physical creature. However, once they ate from the fruit, that pull towards the material became more than a temptation, it became personal, and internal, and this caused mankind to actually desire things that were not simply material, but forbidden (1:3:8):
With his sin, however, deficiencies were added; and they grew in the
essence of man and in all of the entire creation. Moreover the redress
became more difficult than before. The explanation of this is that
surely at the beginning it was easy for [man] to go away from the
deficiency planted in him and to acquire perfection. For the Supreme
Wisdom set up the things like this according to the traits of good and
fairness. And since man was not the cause of the evil and the
deficiency within him - but it was rather planted in him in his
creation - when he removed himself from the evil and turned to the
good, he was surely immediately able to go away from deficiency and
acquire perfection. However with his sin - since it was through him
that perfection became more hidden than it was and the deficiencies
grew, and he was the one that caused evil to himself - it would no
longer be as easy for him to return and to go away from deficiency and
acquire perfection as it was at the time that he was not the cause of
his deficiency, but was rather [just] created like that from his
beginning, as I have written. All the more so [would it be harder], as
the striving required of him now to reach perfection would perforce be
doubled: For he would first need that man and the world return to the
condition that existed at the beginning before the sin; and then
afterwards to rise above that condition to a condition of perfection
to which it was fit for man to rise.
Basically, Adam and Eve developed a great pleasure in doing good and evil, and passed this on to their children. The goal of the children now is to conquer this, so that they refrain from doing evil, even if it is pleasureable and tempting, and thereby fix this pollution, and cleanse it so that mankind can be indeed unique in this world - made in the Image of Hashem.
This lowly state could have been climbed out of by every nation right up until the Tower of Bavel (see Derech Hashem 2:2), and the door was finally sealed when the Torah was given. At that point it became clear that only Abraham's children were going to be able to take up the mantle of fulfilling God's will of acquiring spiritual perfection and raising the world up with them, on a national level. Nations could not elevate themselves as a whole to the stature of man before the sin, but individuals in those nations could by attaching to the Torah through the people of Israel.
Until Israel finishes the job, there will continue to be this very great darkness in the world, Hashem's face hidden, and therefore a world where it seems like evil is a real force that is always gaining the upper hand.