Gurbani makes it clear that all diseases are a result of forgetting Parmeshar Vaheguru:
ਪਰਮੇਸਰ ਤੇ ਭੁਲਿਆਂ ਵਿਆਪਨਿ ਸਭੇ ਰੋਗ ॥
(All diseases befall (on the jeev) when Vaheguru is forgotten).
Since the cause of all diseases is forgetting Vaheguru, therefore the cure would be to stop forgetting Vaheguru i.e. remembering Naam:
ਸਿਮਰਤ ਸਿਮਰਤ ਪ੍ਰਭ ਕਾ ਨਾਉ ॥
ਸਗਲ ਰੋਗ ਕਾ ਬਿਨਸਿਆ ਥਾਉ ॥2॥
(By chanting Prabhu's Naam again and again, house or dwelling of all diseases got destroyed.)
Throughout Gurbani, this Daas has never seen a biological or worldly cause or cure of a disease. Gurbani and Naam in itself are capable of removing all mental, physical and spiritual diseases.
Some of the probable reasons why some Gurmukhs had diseases are following:
1. They had Pralabadh Karma from previous lives and in this life, they had to endure a much lower proportion of their Karma. As an example, if they were to get severely injured, they would only get a scratch instead. The Pralabadh Karma never gets destroyed but gets greatly reduced.
2. They get disease not because of their Karma but because Guru Sahib wants to give the world some important spiritual lessons.
The whole world comes to this world because of bondage of Karma but our Guru Sahibaan did not come to this world because of some bondage of Karma. Their coming to this world is explained by these Gurbani Pankitis:
ਜਨਮ ਮਰਣ ਦੁਹਹੂ ਮਹਿ ਨਾਹੀ ਜਨ ਪਰਉਪਕਾਰੀ ਆਏ ॥
ਜੀਅ ਦਾਨੁ ਦੇ ਭਗਤੀ ਲਾਇਨਿ ਹਰਿ ਸਿਉ ਲੈਨਿ ਮਿਲਾਏ ॥2॥
(They are not bonded in the bondages of birth and death; they are Parupkaari Jan (ones who come to help others) who have come to this world. They give jee-daan (charity of Life) and enable others to meet Vaheguru).
So any worldly problems that our Guru Sahibaan faced were not a result of any Karam-gati but because Vaheguru jee wanted to give important spiritual lessons to the world. Similar to Guru Sahibaan, there are rare Gurmukhs as well who come to this world to revive Dharma. They don’t start a new religion but stay within Gurmat, and live the life of Gursikhs, and connect people to Gursikhi. They too are free of bonds of Karma and any worldly sufferings that they are perceived to be suffering are not a result of any Karma.
Guru Sahib knows better.