Saving a life overrides Shabbat, as the Torah states: “Keep My decrees and laws, which a person shall do and live by; I am the Lord” (Vayikra 18:5). The Sages expound: “‘live by’ – and not die by” (Yoma 85b); the mitzvot of the Torah were given so that people may live by them, not die to fulfill them.
We desecrate Shabbat to attempt a rescue, even if the chances of its success are slim. Thus, we desecrate Shabbat to bring someone medication, even if it works in only a small percentage of cases, and even if it is an experimental drug that might not be effective. However, we do not desecrate Shabbat to acquire a drug if there is no substantive reason to think that it might help (MA 328:1; Rema, YD 155:3; Orĥot Shabbat 20:7).
In a case of uncertainty, we still desecrate Shabbat. For example, if a building collapses, and we do not know whether anyone was inside, and even if someone was inside, we do not know whether he is still alive, we clear away the rubble on Shabbat despite the uncertainty (SA 329:2-5). The act of clearing rubble (“mefakĥin et ha-gal”) lends its name to the general category of piku’aĥ nefesh, which overrides Shabbat.
Even if a rescue attempt fails, God rewards all who made an effort. Similarly, if several people drove to different places to obtain a certain medicine that someone needed, they all receive divine reward, even though some of them traveled for naught (Menaĥot 64a; SA 328:15).
Even though one may desecrate Shabbat to save a sick person, one who knows that he will need to care for a dangerously sick person on Shabbat should prepare as much as possible beforehand to minimize the melakhot he will perform on Shabbat, since one must prepare for Shabbat before Shabbat (MB 344:11). If it is uncertain whether one will need to care for a sick person on Shabbat, it is good for him to prepare before Shabbat, though it is not obligatory (MB 330:1). For instance, if one sometimes is called upon to care for the wounded, he should preferably prepare adhesive and cloth bandages before Shabbat so that he will not have to cut them on Shabbat.
It is good for a woman who is due to give birth to prepare her hospital bag before Shabbat. If the expectant couple is planning to drive to the hospital in their car, they should preferably remove unnecessary items from the car before Shabbat. However, the expectant mother does not need to spend the Shabbatot near her due date close to the hospital, as that is an excessive burden that one is not required to undertake on Friday. If she has to travel to the hospital on Shabbat, she may do so, since saving a life overrides Shabbat (SSK 32:34 and 36:6-7).