Rav Ofer Livnat - Hemdat HaDaf Hayomi
The Gemara (74a) states that for all prohibitions one should transgress and not be killed, with the exception of three prohibitions, which require him to be killed and not transgress. The three prohibitions are idolatry, forbidden sexual relationships (arayot), and murder.
The Gemara states that the source that teaches that one must give up his life and not murder is learnt from logic: "who says that your blood is redder, perhaps his blood is redder." In other words, one may not save one's life at the expense of someone else's life, since one can't assume that his life is more precious then someone else's.
The Tosfos (74b d"h veha) state since the source for murder is logic, there is a case where this logic works in the opposite direction. The case is where a person is being forced to kill someone else passively. For example, when they want to throw him on a baby, and if he wants to prevent this he must act. In this case, say the Tosafot, we say that who's to say that the other person's blood is redder and that I must prevent his death at the expense of my life. Thus, in such a case, even though there is a prohibition of murder, one should transgress and not be killed.
However, Rabbeinu Chaim Halevi (on the Rambam Hilchos Yesodei Hatorah 5, 1) infers from the Rambam that he disagrees with the Tosfos. He explains that, according to the Rambam, the Gemara does not mean that each case should be examined according to the logic that one life cannot take precedence over another. Rather, the Gemara means that, since one life is no more valuable then another, the prohibition of murder cannot be overridden by a threat to one's life. Therefore, in any case where a person is presented with a choice between murder or danger to one’s life, one must forfeit one’s life and not transgress the prohibition of murder.
This disagreement has a ramification regarding forbidden relationships, since the Gemara explains that the source that teaches that one must be killed and not transgress a forbidden relationship is learnt from the fact that the Torah (Devarim 22, 26) compares forbidden relationships to murder. Therefore, according to the Tosafot, for forbidden relationships as well, if a person is forced to take part passively and not actively, he is not required to be killed. However, according to the Rambam, in any case he must be killed and not transgress.
Summary and Ruling:
The Rishonim disagree whether the obligation to be killed and not transgress for murder and forbidden relationships is only where a person is required to take action, or even when passive participation is required. The Rema (Y. D. 157,1) rules that only when a person is required to take action must one be killed and not transgress.
