CREATION OF FREE WILL

All things visible and invisible are created by God.  This is the preamble of the Nicene Creed.
The Bible starts with this statement.:

Gen 1:1  In the beginning God created the heavens and the earth.  One of the basic assumption of Christian faith is that there are other beings – consciousness – other than man.  Heavens in plural indicates a large number of  other dimensions other than material realm.  Beings exist in all these realms sharing various dimensions.  Just as man shares both spiritual and material realms, other heavenly beings (does not imply any holy status) also share multiple dimensions.

The word "Theodicy" was invented by Gottfried Wilhelm Leibniz.

 

In his "Essais de Théodicée sur la bonte de Dieu, la liberté de l'homme et l'origine du mal".  (1710) he defended the justice of God in spite of the existence of evil. God, the highest monad, who is omnipotent and omniscient, is able to do that which is logically best according to His logic limited by the conditions given.  

 

There must be a given condition that disables God to eliminate the need for evil.  Since (at least as we see it) it is a constraint on God, this has to be something which God in his sovereignity conferred.  The condition that requires such a contradiction is nothing but the freedom He gave to His Sons – the privilege of sharing in the divinity of God - so that they can act as their own standards. Certain factors may each be independently possible but mutually incompatible, and, because God created the world under these limitations, the created world is indeed "the best of all possible worlds”

There is also the purpose.  Why was this possibility permitted by God.  While every freedom involves a responsibility to the individual, every mistake is a means of maturing.  Thus evil (pain, suffering) is a tool in the process of becoming.  The aim is that we will in all things grow up into him who is the Head, that is, “ you may be made complete as God himself is complete. “