Praise be to Allah.
Sickness is a test and trial. The Prophet (blessings and peace of Allah be upon him) told us that a person should not wish for tests and trials, as he said: “O people, do not wish to meet the enemy, and ask Allah for well-being, but if you do meet them [the enemy], then be patient and steadfast.” Narrated by al-Bukhaari (2966).
Ibn al-Mulaqqin said: What this means is that it is not allowed to wish for unpleasant and harsh things and to throw oneself into dangerous situations. Hence the salaf (early generations) asked for well-being and to be protected from trials and tests, because people vary in terms of their ability to bear tests and trials with patience and steadfastness.
End quote from at-Tawdeeh li Sharh al-Jaami‘ as-Saheeh (32/633).
According to the hadith, the Prophet (blessings and peace of Allah be upon him) said: “Ask Allah for well-being in this world and the hereafter.” Narrated by at-Tirmidhi (3603).
There are many hadiths from the Prophet (blessings and peace of Allah be upon him) which speak of asking Allah for well-being and instruct us to ask Allah, may He be exalted, for well-being in our bodies, wealth, families and faith.
It was narrated that ‘Abdullah ibn ‘Umar (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) never failed to say these supplications when evening came and when morning came:
“Allaahumma inni as’aluka al-‘aafiyah fi’l-dunya wa’l-aakhirah. Allaahumma inni as’aluka al-‘afw wa’l-‘aafiyah fi deeni wa dunyaaya wa ahli wa maali. Allaahumma astur ‘awraati wa aamin raw‘aati. Allaahumma ihfazni min bayna yadayya wa min khalfi wa ‘an yameeni wa ‘an shimaali wa min fawqi wa a‘oodhu bi ‘azamatika an ughtaala min tahti (O Allah, I ask You for well-being in this world and in the Hereafter. O Allah, I ask You for forgiveness and well-being in my religious and worldly affairs, and my family and my wealth. O Allah, conceal my faults and keep me safe from the things that I fear. O Allah, protect me from before and from behind, and on my right and on my left and from above, and I seek refuge in Your greatness from receiving unexpected harm from below me).”
Abu Dawood said: Wakee‘ said: Meaning being swallowed up by the earth. Narrated by Abu Dawood (5074) and others; classed as saheeh by al-Albaani.
The best thing to do when one is sick is to seek healing from Allah, may He be exalted, whilst bearing it with patience. Hence there are many du‘aa’s (supplications) for seeking healing whilst bearing it with patience, that have been narrated soundly from the Prophet (blessings and peace of Allah be upon him) including the following: It was narrated that ‘Abd al-‘Azeez said: Thaabit and I went to see Anas ibn Maalik, and Thaabit said: O Abu Hamzah, I am sick. Anas said: Shall I not do ruqyah for you with the ruqyah of the Messenger of Allah (blessings and peace of Allah be upon him)? He said: Yes. He said: Allaahumma Rabb an-naas, mudhhib al-ba’s, ishfi anta ash-Shaafi, laa shaafiya illa anta, shifaa’an laa yughaadir saqaman (O Allah, Lord of mankind, the One Who relieves hardship, grant healing, for there is no healer but You, a healing that leaves no trace of sickness) . Narrated by al-Bukhaari (5724).
It was narrated that ‘Aa’ishah (may Allah be pleased with her) said: The Messenger of Allah (peace and blessings of Allah be upon him) used to tell me to recite ruqyah for protection against the evil eye. Narrated by al-Bukhaari (5738).
It was narrated from ‘Abd ar-Rahmaan ibn al-Aswad that his father said: I asked ‘Aa’ishah about ruqyah for fever, and she said: The Prophet (blessings and peace of Allah be upon him) granted a concession allowing ruqyah for treating every venomous sting. Narrated by al-Bukhaari (5741) and Ahmad (23805).
To sum up: seeking to be relieved of harm is the best and most perfect way, and is in accordance with Islamic guidance and sound human nature.
For more information, please see question no. 120175.
If someone chooses to bear sickness with patience, focusing on what that brings of expiation for sins and attaining good deeds, so he does not ask Allah, may He be exalted, for healing, and he does not try to seek medical treatment for it, then he is not to be criticized for that, on condition that he is confident that he will be able to bear the sickness and its hardship with patience, for there were some among the salaf who did that.
But these are exceptional cases, and that is an option only for one who knows that he will be able to bear the pain and suffering with patience, and will not be angry or discontent with what he encounters of that.
Undoubtedly the best and most perfect way, which is suited to most people, is the teaching and practice of the Prophet (blessings and peace of Allah be upon him,, which is to ask Allah for well-being, then if sickness befalls one, to seek medical treatment for it with permissible means, and to ask Allah, may He be exalted, for healing, and it is prescribed for his Muslim brothers to also ask for healing for him.
See question no. 81973 for information on the ruling on seeking medical treatment.
And Allah knows best.