Here’s a brief response to that:
So why doesn’t Allah create only those whom He knows will use their free will properly? The answer is: he did, trillions of them. They are the angels. They have intellect and free will, and there’s nothing but goodness in them. They always use their free will to obey God and do good. And Allah has filled the universe with them.
After creating them, Allah wanted to create a creation that could be potentially be higher than them. One way to do that is to give this being free will and the capacity to do evil. When the human uses his free will to choose good, he is potentially higher than angels. Now if Allah would create only those whom would be good, then there is no trial. How are they tried when there is no evil around them? There must be evil around us to choose goodness. If there is no evil around me then how do I get tried? That’s like having a multiple choice exam without any wrong answers in the options. That’s not a test. Allah’s wisdom dictated that we should be given a chance, we should be tried, and that can be achieved if both are given a chance—those who would choose good and those who would choose bad.
Hope this makes sense.