Your question is a good one. It is one example of a wide range of similar problems. What about the person who dies before birth or immediately after birth? What about the person who was at one time completely sane and lucid, but who becomes extremely senile? Will they become unsenile in the afterlife? Are really smart people in this life smarter in the afterlife than people who were not as smart in this life?
My answer is that I do not know, and I do not presume to know. The Bible does not address any of these questions–at least not directly. In order to even attempt to answer such questions I must resort to speculation, and I generally hesitate to overly speculate. My response, generally, is that I trust God and I trust his wisdom to do what is right for people in any of these categories, including those who have extreme mental illness in this life. I personally believe that children who do not reach the “age of accountability” will be with God for eternity, but I do not claim to understand what their eternal reality will be like. The same may apply to those who had extreme mental illness throughout their lives. I believe that those with extreme physical problems will not inherit those problems in eternity. I therefore speculate (and remember, this is merely my speculation) that those who were disciples of Jesus and those who put their faith in Jesus, but who end up in a state of extreme mental illness will be restored to a state in which they no longer have such mental illness.
There is a whole range of possible situations, such as a person who became mentally ill later in life, but who lived the life of a sinner before that time. There is the case of mentally deficient people who never had the capability of being accountable before God–who were, in essence, permanent children. I cannot give a definitive answer to these questions. Instead I will simply say that I trust God’s fairness, compassion and love (but also his justice and holiness) in these cases.