God doesn't make mistakes, but sometimes gives us special gifts to help us reach our full potential. We might see those gifts as tests, or challenges, or even a terrible and unfortunate thing, but our task is to accept these things, work with them, and return them to God at the end of our lives as best improved as we can.
That's where free will comes in.
I was born into a family that was well off, with intelligent parents, and had the genetics and home that would make life pretty easy. I think God saw that and and determined that a special gift was appropriate to help me grow to my potential. He caused my mothers doctor to prescribe a medication while I was growing in her that made my brain ready to receive a female soul. Given this gift, I could bury it, and have nothing in addition to return to God at the end of my life, or I could invest it, improve it, work with it to return it to God multiplied manifold. There are those in society who would have me bury it, contrary to what Jesus teaches us in the Parable of the Talents, but these are like the hypocrites cast out of the Temple, and I ignore them.
(12 years of Jesuit training... ๐ )