Shalom dear Rabbi,
Question: I wonder if any book in Judaism (Kabbalah) speaks why children are born with physical or mental defect?
You are asking an important question. Often when things happen to small children we wonder, why were they born this way? They are only a small child and haven’t done anything wrong? We can’t know for certain why H-shem does things, however there are some ideas given. One of them (though I don’t recall which sefer it is in offhand) is the idea of gilgul neshamos- reincarnation. In the kabalistic works it is well known that there are times that H-shem will send a soul down to this world in order to correct something that was done in a previous life. Sometimes the persons goal is to accomplish and build things in this world, sometimes it is to deal with certain unique situations, and sometimes the goal of this person’s life is to overcome a certain defect that he was born with. I once saw such an idea, (I think I was from the Chofetz Chaim) who brings out this idea. For example, a person that was a tzaddik, and learnt a lot of torah and did a lot of good deeds, but he spoke lashon hora. His Soul came in front of the heavenly tribunal, and he was given the choice, either to suffer the agonies of gehinnom, or to come back down to this world again and correct what he did. The soul chose to come back to this world, however it said, that doing so is risky, because when he comes back, he might again engage in speaking and hearing lashon hora. For this the heavenly tribunal, told him, “no problem, we can send you back to this world, and you won’t be able to hear, this way, you won’t hear lashon hora. The soul happily agreed. After he was born, he no longer remembered, what he told the heavenly tribunal, and things were difficult for him. He doesn’t realize that his whole success in this world is his being hard of hearing, because after he is finished doing the job he was sent to this world to do, he will return his soul to heaven, and it will be given its proper place for eternity.
There is a fascinating Midrash brough by Rabeinu Bachya (Deuteronomy 22-8) that says that no soul comes down to this world before it is explained the difficulties that it will have, (and knowing why they are supposed to be that way) and that the soul signs and agrees and is happy to enter this world under those conditions!
Again, we can’t know why H-shem, the One who feeds the whole world, and keeps us all alive, has decided that this person should be created in a certain way. However we can investigate, and strengthen our emuna, because at the end of the day, we know that whatever he does is for our ultimate good.