Our Gemara on Amud Aleph discusses the idea that a Cohen may be prohibited from entering a room where there is a Goses (a person who is about to die). This is not merely a rabbinic prohibition in case the person might die and then the Cohen would be in the same room as a corpse. Rather this is a Biblical prohibition, and applies even if the person does not die.
Rishonim ask, since Eliyahu the Prophet was a Cohen according to tradition (Bava Metzi’a 114b), how was he able to enter the room of the dead boy in order to revive him (Melachim I:17:17-23)? Tosafos (ibid) answers that it was permitted in order to save the boy’s life.
If we take Tosafos’ answer simply, I believe there is still a problem. One can argue that saving a life takes precedence over other mitzvos so long as the person is alive. Here, the child was dead! Yes, technically, Eliyahu saved him and BROUGHT him BACK to life, but at the point of Eliyahu’s entry, the child was dead already, and no mitzvah of saving a life technically applies.
Rabbenu Peretz (see Shitta Mekubetzes ibid) may be trying to avoid this problem when he suggests that the boy was not actually dead, but merely very far gone and almost dead with imperceptible vital signs. However, asks Rabbenu Peretz, if so, according to our Gemara, Eliyahu still should have been forbidden to enter the room because the child was a Goses. Rabbenu Peretz answers that since Eliyahu knew that he would bring him back to life, the prohibition of Goses did not apply (According to Ta’anis 23a, Eliyahu possessed the “keys to revive the dead”, that is he had the power from God to revive the dead at will.) This a answer also has difficulties, as the prohibition of Goses seems to be applicable based on the current state. Apparently, Rabbenu Peretz believed that even though the prohibition was Biblical, the reason is only due to impending death, and therefore not applicable if the child was not going to die in the end.
The Netziv ( העמק שאלה שאילתא קס"ז אות י"ז ) notes two different rationales that allow for saving a life to override other commandments. The Gemara (Yoma 85b) states:
רַבִּי שִׁמְעוֹן בֶּן מְנַסְיָא אוֹמֵר: ״וְשָׁמְרוּ בְנֵי יִשְׂרָאֵל אֶת הַשַּׁבָּת״, אָמְרָה תּוֹרָה: חַלֵּל עָלָיו שַׁבָּת אַחַת כְּדֵי שֶׁיִּשְׁמוֹר שַׁבָּתוֹת הַרְבֵּה. אָמַר רַב יְהוּדָה אָמַר שְׁמוּאֵל: אִי הֲוַאי הָתָם, הֲוָה אָמֵינָא דִּידִי עֲדִיפָא מִדִּידְהוּ: ״וְחַי בָּהֶם״ — וְלֹא שֶׁיָּמוּת בָּהֶם.
Rabbi Shimon ben Menasya said: It is stated: “And the children of Israel shall keep Shabbat, to observe Shabbat” (Exodus 31:16). The Torah said: Desecrate one Shabbat on his behalf so he will observe many Shabbatot. Rav Yehuda said that Shmuel said: If I would have been there among those Sages who debated this question, I would have said that my proof is preferable to theirs, as it states: “You shall keep My statutes and My ordinances, which a person shall do and live by them” (Leviticus 18:5), and not that he should die by them. In all circumstances, one must take care not to die as a result of fulfilling the mitzvot.
Therefore, violating other mitzvos in order to save a life can either be by fiat from to the Biblical exemption, that one must LIVE by the mitzvos, or the more logical idea that it is worthwhile to desecrate Shabbos one time in order to allow the person to live and keep many Shabbosim. And by extension, desecrate any mitzvah in order that the person live and fulfills many more mitzvos.
The Netziv argues that this logic-based dispensation would only be allowed if one is reasonably sure that a life could be saved, because only then does the moral calculus of violating a single prohibition to preserve long-term fulfillment of mitzvos applies. However, the Biblical exemption to live through the mitzvos teaches that one may desecrate the Shabbos or override other mitzvos to save a life even if it is a long shot, because that is still about attempting to live by the Torah.
Some use the Netziv’s distinction to explain Tosafos’s answer. True, the child was dead, so the regular rule of overriding a prohibition to save a life did not apply. But since Eliyahu knew that he could revive the lad, he used the logical argument that violating one prohibition is permitted for the sake of providing for a lifetime of mitzvos.
Interestingly, this argument is also used to save another kind of child. Shulkhan Arukh OC (306:14) and Bais Yosef (ibid) discuss a case where a child is being taken away by gentiles for religious indoctrination. It is permitted to violate the techum (and according to Bais Yosef other Biblical prohibitions as well) in order to save this child. The rationale is again based on the logic of allowing one violation in order to preserve future Torah observance.
The poskim point out that the particular case is only permitted if the child was innocent and did not run off (see Rashbah quoted by Bais Yosef). This is because one does not commit a sin to save a fellow Jew from willfully committing a sin.
An interesting question is how this might apply to a confused and unhappy child or adolescent who is not so innocent, but maybe not so guilty either. For such a child, what allowances or accommodations could be made in order to preserve his or her continued observance? It would seem to depend on how we evaluate the mental state of the child to determine if this is neglectful and willful behavior, or due to such emotional distress that there is no liability. However, if we assume a compromised mental state to that degree, perhaps it is intrinsically a state of pikuach nefesh, and doesn’t require any additional rationales.