The Talmud answers: That stands to reason, since betrothal takes effect with those women who are forbidden and with whom he would be liable for the violation of a prohibition. That is, if a man betroths a woman who is forbidden to him and with whom he would be liable for the violation of a prohibition, then although he violates a prohibition in doing so, the betrothal is valid and cannot be ended without a bill of divorce. Therefore, such a woman also requires ḥalitza. In contrast, betrothal does not take effect at all with those who are forbidden and would be liable to receive the punishment of karet, and therefore in these cases the laws of levirate marriage and ḥalitza do not apply at all.
מתיב רבא: איסור מצוה ואיסור קדושה, בא עליה או חלץ לה — נפטרה צרתה. ואי סלקא דעתך חייבי לאוין מדאורייתא לחליצה רמיא, לייבום לא רמיא, כי בא עליה — אמאי נפטרה צרתה?
Rava raised an objection to the explanation of Rav: It is taught in a baraita with regard to a prohibition resulting from a mitzva and a prohibition stemming from sanctity that if he has sex with such a woman or performs ḥalitza with her, her rival wife is exempt, even though it was prohibited for him to have had sex with her in the first place. If it enters your mind that women who are forbidden, as he would be liable for the violation of a prohibition, require ḥalitza by Torah law but do not require levirate marriage, then when he has sex with his yevama why is her rival wife exempt? If there is no biblical mitzva to have sex with her, his action would carry no halakhic validity and the rival wife should not be exempt.