If someone died immediately after illness while they have not completely recovered in order to make up for the missed days of fasting, then there is no sin upon them, in which case the children or relatives are not required to do anything. However, if the person recovered without making up for the days missed, then the relatives may either fast the days on which they broke the fast or feed a needy person two satisfying meals for each day.
In this regard, Imam An-Nawawi, who is a Shafi`i scholar, states the following in his book Al-Majmu`: Scholars have different opinions regarding the person who misses some days of fasting because of illness or travel then dies without making up for them. The Shafi`i scholars are unanimously of the opinion that there is no sin on such a person. They further say that no one is to fast on behalf of him/her or feed needy persons for the days he/she missed.

This is the opinion adopted by imams Abu Hanifah, Malik and the majority of scholars. Moreover, Al-`Abdari says, “This is the opinion of all scholars except Tawus and Qatadah who say that a needy person is to be fed for every day that the person missed. They base their opinion on the fact that this person (who has died) cannot fast and thus he should have the ruling of old people.”
Al-Bayhaqi and other scholars who follow, along with us, the Shafi`i school, refute that opinion (of Tawus and Qatadah) quoting the hadith from Abu Hurayrah narrated from the Prophet (peace and blessings be upon him) stating that: If I order you to do something, then do of it as much as you can. (Reported by Al-Bukhari and Muslim). They (Al-Bayhaqi and other Shafi`i scholars) further disapprove of the analogy those scholars have drawn with the case of Hajj. The Shafi`i scholars differentiate between the case under discussion and that of old people by the fact that the aged person is still liable for obligations which is not the case of the dead.

Another Shafi`i scholar, namely Ash-Shirazi, states in his book Al-Muhadhdhab:

If someone dies while he has missed fasting some days in Ramadan, his case should be considered. That is, if he has delayed fasting them because of a legal excuse which has continued until his death, then he is free from any liability, as it is an obligation which he could not fulfill until he died, so such a person is absolved from the responsibility of this legal duty.

In his book Al-MughniIbn Qudamah, a prominent Hanbali scholar, states:

As regards the person who dies while there are some days of Ramadan for which he has not made up, there are two cases:
First, he may have died before being able to fast because there was no time for fasting, or for a legal excuse such as illness or travel, or because of being unable to fast. Such a person is absolved from any liability according to the majority of scholars. However, Tawus and Qatadah (as mentioned above) are of the opinion that a needy person is to be fed for every day that the dead person missed. According to them (Tawus and Qatadah), the dead person has missed days of obligatory fasting and thus needy persons are to be fed as an atonement for these days. They further regard such a person’s case in the same way as that of an old man who cannot observe fasting.
On the other hand, the majority of scholars base their opinion on the fact that such fasting is a right of Allah which is obligated according to the Shari`ah, and such a person has died before being able to observe it, thus, this dead person is absolved from this right without being required to perform another obligation in place
of it. This is the same as the case of not performing Hajj. Furthermore, the case of such a dead person is not to be compared with that of the old man who is originally obligated to perform that duty unlike the deceased.
Second, such a person may have died after being able to observe the fast, in which case, a needy person is to be fed for every day that the dead person missed. This is the opinion adopted by the majority of scholars.

Concerning the same issue, Dr. Yusuf Al-Qaradawi states:

If an ill or a traveling person dies while being in the same state of illness or travel, then they are not obligated to make up for the days they missed, for neither of them have been able to reach the time when they could have made up for the missed days. However, if an ill person recovers and the traveler reaches a place of residence, and then they die, then they are both considered liable to atone for the missed days in accordance with the period they stayed in good health (in case of the ill person) or in residence (in case of the traveler).
The liability here can be discharged through either of the following two ways:
First, one of the guardians of the deceased should fast on behalf of him/her. This is according to the hadith `A’ishah narrated from the Prophet (peace and blessings be upon him) which reads: “Whoever dies while he ought to have fasted (the missed days of Ramadan), his guardian(s) should fast on his/her behalf.” (Reported by Al-Bukhari and Muslim) Al-Bazzar has reported the same hadith with the following addition: “…if he (the guardian(s)) wills.” Commenting on this hadith, Al-Haythami states in his book Majma` Az-Zawa’id, “This hadith is narrated through a good chain of transmitters.”
Thus, the guardian(s) should fast on behalf of the de
ceased as a matter of doing good to the deceased not as an obligation which the guardian must fulfill. This view is substantiated by the hadith narrated on the authority of Ibn `Abbas that a man came to the Prophet (peace and blessings be upon him) and said, “O Allah’s Messenger! My mother died and she ought to have fasted one month (i.e., she missed one Ramadan); shall I fast on her behalf?” The Prophet replied in the affirmative and said, “Allah’s debts have more right to be paid.” (Reported by Al-Bukhari and Muslim)
It is well-known that one is not required to settle the debts of others except as a matter of doing good. This is because one is not obliged to fulfill others’ duties, and thus one can – but is not obliged to – fast on behalf of the deceased, and by this fasting the deceased’s liability is discharged.
Second, the deceased’s liability can be discharged also by feeding a needy person for every day the deceased has missed, for this fasting is regarded as a debt in the sight of Allah which must be fulfilled from the deceased’s estate, as Allah’s debt has more right to be settled. Some scholars stipulate that the deceased should have determined that in his/her will; otherwise, nothing of the estate should be given to the needy, for the estate in this case has become the right of the inheritors. However, the sound opinion is that the estate becomes the right of the inheritors after fulfilling the legacies the deceased may have bequeathed and/or settling his debts, and the money given for atonement is the right of the needy which must be paid.