Quran 7:179 – Humans Made For Hell
God knew all in advance, but he decided to let it happen. This is not the test of his knowledge but our test to achieve a status. He is not not just merciful, He is the creator, King and lord of the people who wanted the things this way. He has given us chance to achieve eternal blessings for a very short span of time in the world but if some deliberately fail, He decided to send them to Hell as they refuse to earn His blessings.
Many thanks for explanation.