Why did God create people who are mentally ill or severely handicapped? They are not able to serve him in the same capacity and their lives seem to be full of difficulty and anguish. Why would God do such a thing?
I have heard anecdotally that these types of individuals (as well as children who die in infancy) posses souls that have been reincarnated in order to achieve a very slight thing that was omitted in a previous gilgul (soul-incarnation). God always gives people the tools they need to achieve their goals in this world, therefore if God gave these people less "tools" they must not need them in order to achieve the purpose they were put here for. Thus these people posses very rarefied souls who are extremely close to their ultimate tikkun. It is said that the Chazon Ish would stand up in the presence of such people for this reason.
...The father [of the disabled child], in honor of his son's bar mitzvah, took him to receive a brocha from the Chazon Ish. He made an appointment, and as he walked through the door, the Chazon Ish stood up. The father thought someone was coming in behind him, so he turned around to see if it was a Rosh Yeshiva, but there was nobody there. He said, "Rebbe, I'm just a simple Jew, please don't stand up." The Chazon Ish replied, "I'm not standing up for you; I'm standing up for your son. Don't you understand? He's from the higher neshamos of this world, this little child."
The following story is from Rabbi Paysach Krohn, Echoes of the Maggid. It is one of my favorites. I believe that those that are imperfect are here in order for us to perfect ourselves.
A young boy, Shaya, attends a special school during the week, Chush, for learning-disabled children. He loves baseball, but because of his lack of coordination isn't often chosen to play. One time Shaya came to Yeshiva Darchei Torah, where he learned on Sundays, as his classmates were playing ball. His father asks if Shaya can play. Being six runs behind and in the eighth inning, they figured, "Why not?" and Shaya went out to play short center field. I will now let the master story teller, Rabbi Krohn, take over the telling of the story:
"In the bottom of the eighth inning, Shaya's team scored a few runs, but was still behind by three. In the bottom of the ninth inning, Shaya's team scored again and now with two outs and the bases loaded and the potential winning runs on base, Shaya was scheduled to be up. Would the team actually let Shaya bat at this juncture and give away their chance to win the game? "Surprisingly, Shaya was told to take a bat and try to get a hit. Everyone knew that it was all but impossible, for Shaya didn't even know how to hold the bat properly, let alone hit with it. However, as Shaya stepped up to the plate, the pitcher moved in a few steps to lob the ball in softly so that Shaya should at least be able to make contact. "The first pitch came in and Shaya swung clumsily and missed. One of Shaya's teammates came up to Shaya and together they held the bat and faced the pitcher waiting for the next pitch. The pitcher again took a few steps forward to toss the ball softly towards Shaya. "As the next pitch came in, Shaya and his teammate swung the bat and together they hit a slow ground ball to the pitcher. The pitcher picked up the soft grounder and could easily have thrown the ball to the first baseman. Shay would have been out and that would have ended the game. "Instead, the pitcher took the ball and threw it on a high arc to right field, far and wide beyond the first baseman's reach. Everyone started yelling, 'Shaya, run to first! Shaya, run to first!' Never in his life had Shaya run to first. "He scampered down the baseline wide-eyed and startled. By the time he reached first base, the right fielder had the ball. He could have thrown the ball to the second baseman who would tag out Shaya, who was still running. But the rightfielder understood what the pitcher's intentions were, so he threw the ball high and far over the head of the third baseman's head, as everyone yelled, 'Shaya, run to second! Shaya run to second!' "Shaya ran towards second base as the runners ahead of him deliriously circled the bases towards home. As Shaya reached second base, the opposing shortstop ran towards him, turned him toward the direction of third base and shouted, 'Shay, run to third!' "As Shaya rounded third, the boys from both teams ran behind screaming, 'Shaya, run home! Shaya, run home!" "Shaya ran home, stepped on home plate and all 18 boys lifted him on their shoulders and made him the hero, as he had just hit the 'grand slam' and won the game for his team." Concludes Rabbi Krohn about the lesson of this story, "Too often we seek to find favor and give honor to those who have more than us. But there are people who have fewer friends than we, less money, and less prestige. Those people especially need attention and recognition. We should try to achieve the level of perfection in human relationships which the boys on the ballfield at Yeshiva Darchei Torah achieved. Because if children can do it, we adults should certainly be able to accomplish it as well."
None of G-d's creations exist for no reason. As Rabbi Akiva's teacher, Rabbi Nachum Ish Gam Zu, taught him, gam zu l'tovah -- everything is for the (Divine) Good. What that is, we don't always know. When trouble happens to us, individually, it may be a message from G-d. Talmud Bavli Berachot 5a tells us that when hard times falls on us, individually, we should first look at our deeds. If they are lacking, then we should reform. If not our deeds, then perhaps our Torah study. But if not that, one may be a righteous person whom G-d has placed the burden of punishment that others would have received for their sins, but for G-d's understanding that further punishment would push those people away from Him. These are called "Afflictions of Love." We are forbidden, however, to assume that the suffering others receive was punishment for their sins. We don't know and cannot assume, as we learn from the Book of Job.
Rabbi Benjamin Blech, in his book If G-d is Good Why is the World So Bad, addresses this issue head-on pointing out that at all times we have to recognize that (1) G-d is good; (2) G-d is all-powerful; and (3) G-d, in giving us free will, decided to not control our lives as if we were puppets and therefore allows people who choose evil to challenge those who chose good.
So what of the case you raised -- a child suffering from mental or physical ailments? They clearly didn't do anything to merit punishment. No, they didn't. But there may be a Big Picture we don't understand. It is said that G-d created the insane in King David's days so that he could learn by their example and pretend to be insane in order to escape capture. The child might be an opportunity for a young volunteer to learn about helping others and caring more about the needs of others besiders herself. This was my daughter's experience as a teen when she (and many other boys and girls) took care of a boy who had been permanently brain-damaged in a swimming pool accident. My daughter gained so much from that experience that it almost seems that the boy was sent there by G-d for her and others. Rabbi Blech explains that G-d repays the souls of those who had to live such lives. My Rav explained that the boy gained credit for all of the mitzvas done by his young aides and all of their future mitzvas that he inspired them to do, even indirectly.