There are some biblical examples which suggest that God does occasionally use sickness to teach us lessons. One is 1 Corinthians 11:29-30
29 For anyone who eats and drinks without discerning the body eats and drinks judgment on himself. 30 That is why many of you are weak and ill, and some have died.
Because of the way the believers in Corinth were treating the Lord’s supper, God had caused some of them to become ill and even die.
Another example is Job who suffered terrible tragedies including severe illness at the hand of God. See Job chapters 1 and 2. It wasn’t because he had done anything wrong; in fact he was a very righteous man. But it was a time of testing for him, through which he learned a lot about God.
On the other hand, we are clearly told that illness and difficulties can come upon us for entirely different reasons. About a man born blind, Jesus said
“It was not that this man sinned, or his parents, but that the works of God might be displayed in him.” (John 9:3)
And when a tower fell and killed 18 people, Jesus said
“Or those eighteen on whom the tower in Siloam fell and killed them: do you think that they were worse offenders than all the others who lived in Jerusalem? No, I tell you; but unless you repent, you will all likewise perish.” (Luke 13:4-5)
Most often, we don’t know the reason why things happen to us. But we do know that God loves us whatever happens. The important thing is not what happens to us, but how we deal with what happens to us. Through painful times, we often come out stronger and closer to him.
In Hebrews 12:7-11 we are told
7 It is for discipline that you have to endure. God is treating you as sons. For what son is there whom his father does not discipline? … 10 For they disciplined us for a short time as it seemed best to them, but he disciplines us for our good, that we may share his holiness. 11 For the moment all discipline seems painful rather than pleasant, but later it yields the peaceful fruit of righteousness to those who have been trained by it.
It is a mistake to confuse God’s discipline with punishment. Rather, God disciplines us in the sense of trials and character-shaping events that mould us to be more godly and better followers of the Lord. Sometimes those trials might include sickness.