In Parshat Ki Tisa, from the section pertaining to Shabbat, we see that even though its איסורי מלאכה (forbidden acts of work) are stringent, there are certain times when one may violate the restrictions of Shabbat. One of these occasions is the saving of a fellow Jew's life (Pikuach Nefesh). There are various reasons for this, which are quoted Masechet Yoma (דף פה:) (also found in the Midrash Sifrei). R. Natan says if one saves a person's life by violating Shabbat, although the rescuer has desecrated Shabbat, it is permissible because he enables the person he saves to observe many more Shabbatot. Furthermore, R. Yishmael quotes the case of בא במחתרת, one who clandestinely intrudes into a home, and it is unknown if he plans merely to steal or to also kill the home's residents. In this case, one is permitted to save himself from possible danger by killing the intruder, even though his intentions may have only been to rob. R. Yishmael learns the following קל וחומר (logical deduction): If one may rescue himself from possible danger by killing, a destructive act which chases away Hashem's presence, then surely one is allowed to rescue someone in danger by violating Shabbat, which may be a serious prohibition but is not nearly as destructive as killing! A third opinion is that of R. Yosei Haglili, who learns from the word אך in the pasuk (שמות לא:יג) אך את שבתותי תשמרו that Shabbat may or may not be desecrated depending on the circumstances. The word אך generally comes to limit something. Here it limits the observance of Shabbat to when there is no life-threatening danger.
Rishonim discuss this issue as well, debating how exactly to explain the effect of Pikuach Nefesh on Shabbat. The Rambam believes that if there is an incident which requires the saving of a life, then it is permissible to violate Shabbat, but the kedushah of Shabbat remains. In הלכות שבת פרק ב הלכה א, he says that סכנת נפשות, danger to human life, can make Shabbat דחויה, overridden, implying that the rules of Shabbat still apply, but they may be broken if there is no other option. Nonetheless, one must do everything possible to avoid the desecration of Shabbat even when saving a life. The Rosh disagrees, saying that the prohibitions of Shabbat does not apply at all in a case of Pikuach Nefesh. He draws an analogy to the example of cooking on Yom Tov, where one need not attempt to minimize how much he cooks, because the prohibition of cooking does not exist on Yom Tov. Here too, the Rosh believes that the laws of Shabbat are not applicable in a case of Pikuach Nefesh, and one is not required to attempt to save the life without breaking Shabbat.
It is interesting to note that there are so many explanations and interpretations of such a seemingly obvious leniency on Shabbat. I believe that this is not because Chazal were trying to find a loophole in Shabbat, but because they wanted to demonstrate the greatness of Shabbat. It would seem obvious if one's life is in danger that there should be no doubt that saving it should override any other considerations. However, Chazal had much discussion about the permissibility of breaking Shabbat even for Pikuach Nefesh to show how seriously they take Shabbat. On Shabbat, the holiest day of the week, nothing should interfere with one's relationship with God. Chazal demonstrated this by making even the seemingly simple issue of saving a life into a complex one.