Any other agent acting freely, autonomously, is bound to transgress God's will at some point. Though that agent is made in God's likeness, since that agent is not God, that agent cannot independently replicate God's will. God did not, indeed could not, make himself in creating such agents, he merely created something that had a power of will analogous to his own (i.e. they do as they please). To be able to replicate God's will precisely an agent would have to be God.
If that is so, it means that given the decision to create independent, freewill creatures, sin (or evil) would be inevitable. Generally, if something is inevitable it can be said to have the quality of being necessary. If sin (or evil) is necessary to the creation of God's image, that would be sufficient to establish that evil was necessary, at least for the particular good of making creatures in the image of God. Furthermore, if that is the case, sin and evil would have been authored, knowingly, purposely, by God upon the decision to create.
That is not case, however, because the inevitability in question is not the result of a decree from God concerning the agent's will (as in determinism). Instead, the inevitability arises from the agent's distinction from God in identity. The agent sins because he can will like God but isn't God. Therefore, God is not the author of such sin, the free agent is--even though God could foresee such sin and did author the freewill that made it possible.
I have already established that the freedom of will entailed in the image of God was good per se. So, if inevitability does not translate into necessity and the authorship of sin (evil), it cannot lead to the conclusion that evil was necessary for that good to exist. If, in fact, there was a way to unite the identity of God with the identity of the agent, freewill would not necessitate transgression at all, as is ultimately demonstrated by Jesus, the Son of Man.
However, I am forced to conclude that if such unity was not possible, indeed, if it was not God's purpose in creating man in God's image, freewill with it's inevitable failure to sin would have been immoral, even though God was not the author of the sin. If that unity were not possible, the only conceivable end in creating free agents would be to destroy them in judgment. That may be judiciously righteous, but there is no way it could be beneficial to the creature. Redemption had to be baked into the cake at creation, or the cake was baked with evil intent.
Hopefully, it is becoming clear to you, dear reader, that this is all resolved in faith, that is in trusting submission to God. The Bible tells us that Jesus, himself God in the flesh, learned obedience, while in his earthly frame, by the things he suffered. It may not be possible to learn submission in any other way. Even Adam and Eve had their opportunity to learn obedience via this route as they fell to sin, although their test of suffering (self-denial) was meager at best.
It takes freewill in order to express this faith. Paradoxically, that same freewill inevitably leads to sin (and evil). Faith, it seems, is the counterweight to willfulness within the human soul. I think it's safe to say that if faith could have beaten willfulness to the punch, evil would never have existed (at least theoretically).
When a free agent, coaxed by the Spirit of God, voluntarily yields, or submits, to the place of God (Lord) and to the will of God, that one becomes open for God to share his Spirit (person) with. When God's Spirit is fully engaged in such an agent, God's identity is united with the identity of that agent, and the exercise of freewill becomes harmonized with the will of God. That will be the joy of eternity for God and redeemed man.
For the joy set before him, Christ endured the cross, scorning its shame, and sat down at the right hand of the throne of God. Hebrews 12:2