In Mesopotamia, according to Ricœur who follows Heidel et al., the original chaos of a nature in tumult (with all the “stuff” already there) cannot be separated from the genesis of the gods. They don’t predate the world, or at least its unstructured mass. Some have come to existence with matter, other were born from those. Whether the gods are the product of a genesis or as eternal as matter, evil appears to be part of this original chaos: the initial theomachies and creation of man are not all good but incorporate evil. The myths and rituals, as they were played out in ancient ceremonies, repeated the initial struggle. In the context of Mesopotamian city-states and later kingdoms, these ceremonies reinforced the idea that social hierarchies were not the product of a social and economic development, but were set “on high”, and that all sorts of evil were at bottom part of the natural world, without clear separation between the sensible and the divine (as Plato would argue later there was).
In Israel, the divinity was not generated, in any of the stories about the origins of the world. This god appears to be single, clearly so in the most self-reflexive (and elaborated at a later date, exilic and post-exilic most likely) parts of Scripture. Creation is all good, though as presented in Genesis, it is still an ordering of chaotic matter. In the following story of the advent of man and woman, evil is explained as a sort of accident, not as being part of the fabric of the universe (or at least of the universe created by god). The man (האדם) is part of a series, but it is proposed that there is a beginning to evil. The anti-mythic bend of this story goes so far as to make the nephilim and the flood story parts of the fall myth. Yet, even if evil is presented as an accident or an individual occurrence, it seems to be part also of a chain of events which may all be connected to each other (not quite as in Greek tragedy, however, since nature and the divine are much more separated).
It is in the confrontation with exile (Nineveh for northerners, Babylon for southerners), that the idea of a universal god becomes refined, a god who makes a covenant with a small, defeated, kingless, temple-less, nation which has begun to explain its history (and write it) as following a logic of chastisement and return.