An interesting anecdote about free will in the Islamic tradition
𝐀𝐥-𝐀𝐬𝐡𝐚𝐫𝐢: What's the ultimate fate of a disbeliever, a child and a Muslim?
𝐀𝐥-𝐉𝐮𝐛𝐛𝐚𝐢 (his teacher): the disbeliever will reside in Hell, the Muslim will be in the higher levels of Heaven and the child will be saved"
𝐀𝐥-𝐀𝐬𝐡𝐚𝐫𝐢: But if the child says 'Had I the chance to reach adulthood, I would have done the acts of a good Muslim. So it's unfair for me to be denied the highest seats in Heaven (and only be saved) just because I died in childhood'
𝐀𝐥-𝐉𝐮𝐛𝐛𝐚𝐢: God already knew that the child would have disobeyed Him once he came of age. So He caused him to die early so that he would not have to burn in Hell.
But since the highest levels of paradise are reserved for those who were obedient to God (which the child was too small to do), he could not reach those levels
𝐀𝐥-𝐀𝐬𝐡𝐚𝐫𝐢: But the infidel (disbeliever) will object 'God, you also knew that I would disbelieve in adulthood.. so why didn't you kill me too in childhood so that I could he saved from hell?'
𝐀𝐥-𝐉𝐮𝐛𝐛𝐚𝐢 had no answer to this
This conversation is recorded in "Tabaqat as Shafiyya Al Kubra" and is likely apocryphal, but it was used to buttress the Ashari position (represented by Imam Al Ashari above) vis a vis the Mutazalite position (represented by Al Jubbai) on free will and God's nature.
Basically, Mutazalites believed that God is just and wouldn't punish people arbitrarily while Asharis believed that God is not bound by concepts of justice and injustice, and whatever He wills, that becomes just. In short, God is not obliged to always act in the best interests of His creation (called al-aslah), which the Mutazalites believed in. (I'm oversimplifying, obviously)
(H/T: Professor Sean Anthony, who did a thread on this recently)
