Allah/God created humans giving us 'free will' for the following reasons.
Who has created death and life, that he may test you which of you is best in deed. And he is the Almighty, Oft Forgiving. (Qur'an 67:2).
And We have enjoined on man (to be dutiful and good) to his parents. His mother bore him in weakness and hardship upon weakness and hardship, and his weaning is in two years give thanks to Me and to your parents, unto Me is the final destination. (Qur'an 31:14)
And I did not create the jinn and mankind except to worship Me. I do not want from them any provision, nor do I want them to feed Me. (Qur'an 51:56-57)
By observing the above 3 verses, God wants us to have a balance of the above.
He it is Who sends Salat (His blessings) on you, and His angels too (ask Allah to bless and forgive you), that He may bring you out from darkness (of disbelief and polytheism) into light (of Belief and Islamic Monotheism). And He is Ever Most Merciful to the believers. (Quran 33:43)
People burn in hell only because of their deeds. While they're born, God doesn't stamp them that they're to be in hell for sure or pre decide, but tests. So there is no injustice done to them. So, in this God is justifying to us that those who burn in hell deserved it.
But, assuming he had knowledge of future, when he was certain about that, then, He creates as he wishes.
Blessed is He in Whose Hand is the dominion, and He is Able to do all things. (Qur'an 67:1)
May the creator guide us all.