When looked at from a wider perspective, everything has a role in the Plan of Evolution. Within this plan, ailments come about because of the need to bring order into one’s life.  Ailments are an opportunity for human beings to advance and to balance their negative karma.

Beings who are already conscious on the soul level, are aware of their evolutionary goal prior to incarnating. Based on this, they program situations that will provide the necessary developmental experiences during the lifetime about to begin on Earth. Since the soul participates in the design of its own program and has the support of forces made available to it by means of the law of karma, the program always takes into account the level of a person's endurance. In this way, a proposed ailment is never greater than one's capacity to bear it. An ailment only becomes too heavy to bear when the person rejects it or reacts against it. 

When an ailment that has been programmed before birth appears, one has to muster up enough strength from within to transcend that state of infirmity. This strength, which would not have been rallied without the ailment, is not to be used to struggle against the infirmity but to face it intelligently and cooperatively, seeing it as an opportunity to bring about equilibrium. For example, someone who had committed theft, either in the present or in a former incarnation, might have to suffer a chronic ailment in the hands. The effort to treat and to adjust patiently to the malady could, in the overall balance of energies, compensate for the past deed. 

In order to alleviate pain or bear discomfort, one should resort to the strength that comes from within. Ailments could then bring about new understanding and hence, new habits.

“Beyond Karma” pp. 45-46 (English edition)