From Ohr Avigdor Shaar Bechina by Rabbi Avigdor Miller
Hashem is teaching mankind one of the great lessons of life, and that is the ability to take hardships. Why does a child have to suffer from teething? After all, Hashem made everything in a benevolent way. And natural growth is usually not painful. So why is it that the child must endure pains while his teeth are growing in?...
Also the need for children to endure the common childhood illnesses needs to be understood. The child needs to learn from a young age that the world is not only a joyride. From the very beginning he needs to get accustomed to pain. There must be some tolerance of pain in life because pain presents man with a challenge. Without that, a man is uncontrollable. Pain motivates a man to do what is right, for him and for the world. The child must begin to learn this as soon as possible. Although this is a world of happiness, there are limited areas of suffering to prepare the child for this important principle of life.
Most of life is happiness, even for children
When a person suffers pain or discomfort he has no choice but to bear it. And so he makes up his mind to take the pain as long as he can, thus gaining self-control. It is a natural reaction for a person to steel himself to his suffering. The self-control that he learns will enable him to overcome his baser instincts when he is presented with a choice of doing something dangerous or morally wrong.
We start the lesson of being a human being in This World by teaching the child a little bit of yissurim (suffering). Not much. Most of life is happiness, even for children. However, there is a little injection of suffering now and then to make the child aware that This World is not all joy, not all fun. And so the child slowly learns to steel itself and to develop self-control.
And so Hashem is teaching mankind one of the great lessons of life, and that is the ability to take hardships. Of course, He teaches it in very small doses, but those doses are very beneficial.