A yevama shall not undergo yibbum during the time of her niddah, and we do not say that since the prohibition of a brother's wife was permitted, the matter of niddah was also permitted, for they are unrelated matters. Nevertheless, she is eligible for chalitzah, and we do not say regarding this that "anyone who is not eligible for yibbum is not eligible for chalitzah," for this is an external prohibition, as we explained in section 3; see there. And if he transgressed and performed yibbum with her during the time of her niddah, he has acquired her and it is a valid yibbum, even though they transgressed a prohibition of karet. Thus ruled the Rosh at the beginning of Yevamot, and so they ruled in the Tur and Shulchan Aruch, section 4. And the Rosh brought a proof from Pesachim (72b), which says there that if one has relations with his yevama during her niddah, he is exempt from a sacrifice because he performed a mitzvah; see there. It follows that he acquires her if he has relations with her during her niddah; see there. And I wonder, for there in the Gemara it deals with an unintentional act where he did not know she was a niddah, for in his mind he is performing a mitzvah. On the contrary, [if he had relations] near her expected period, it is explained there that it is not a mitzvah, and if he knew she was near her expected period, he is liable for a sin offering. Rather, if he did not know, we say he is exempt because he acted with permission, and the fact that he did not ask her was because he was embarrassed to ask her. And so wrote the Rambam in the second chapter of Shegagot. This is his wording: One who has relations with his yevama and she is a niddah, and he did not know, he is exempt from a sin offering because he acted with permission, etc., for he is not accustomed to her such that he would ask her. Thus far his words. But in an intentional case, when he knew she was a niddah, from where do we know that he acquired her through an act of relations involving a transgression that carries karet? And is this any better than matzah, where one does not fulfill the obligation of matzah with matzah that is prohibited, as explained in the second chapter of Pesachim and in the Rambam, sixth chapter of Chametz; see there? However, from there there is no proof, for we derive that from a verse, "You shall not eat leaven with it" (35a; see there). But here, since there is no derivation for this, we say based on reasoning that he fulfills the mitzvah of yibbum through this. And the proof of the Rosh is from what they said there, that when a skewer of notar was switched for him with a skewer of valid consecrated meat and he ate it, he is liable for a sacrifice, and [the Gemara] distinguishes between this and having relations with his yevama who is a niddah because with notar he does not perform a mitzvah at all. It follows that with his yevama there is at least the mitzvah of yibbum; see there. And one also should not ask: behold, with a stolen lulav we disqualify it even on the second festival day due to the principle of "a mitzvah that comes through a transgression," as is found in Sukkah (30a), and here too it is a mitzvah that comes through a transgression? For Tosafot already wrote there that it is only called "a mitzvah that comes through a transgression" when the mitzvah is performed by means of the transgression, and were it not for the transgression, the mitzvah would not have been performed; see there. But here, even without the transgression, the mitzvah would have been performed when she becomes pure (and this is like a lulav from an asherah, regarding which Tosafot wrote that there is no issue of "a mitzvah that comes through a transgression" in it; see there).
היבמה לא תתייבם בעת נדותה ולא אמרינן כיון שהותרה איסור אשת אח הותרה נמי ענין נדה דאין ענין זל"ז ומ"מ בת חליצה היא ולא אמרינן בזה כל שאינה עולה ליבום אינה עולה לחליצה דזהו איסור מהצד וכמו שבארנו בסעיף ג' ע"ש ואם עבר וייבם אותה בעת נדתה קנאה והוה יבום אף שעברו איסור כרת כן פסק הרא"ש ריש יבמות וכן פסקו בטור וש"ע סעיף ד' והביא הרא"ש ראיה מפסחים (ע"ב:) שאומר שם דאם בעל יבמתו בנדתה פטור מקרבן משום דעבד מצוה ע"ש אלמא דקני לה אם בא עליה בנדתה ע"ש ותמיהני דשם בגמ' מיירי בשוגג דלא ידע שהיא נדה דלדעתו עושה מצוה ואדרבא בסמוך לווסתה מבואר שם דלאו מצוה היא ואם היה יודע שהיא סמוכה לווסתה חייב חטאת אלא שאם לא ידע אמרינן שפטור מפני שעשה ברשות וזה שלא שאל ממנה מפני שהוא מתבייש לשאול ממנה וכ"כ הרמב"ם בפ"ב משגגות וז"ל הבא על יבמתו והרי היא נדה והוא לא ידע ה"ז פטור מחטאת מפני שעשה ברשות וכו' דאינו רגיל בה כדי שישאל לה עכ"ל אבל במזיד כשידע שהיא נדה מנלן דקנה אותה בביאת עבירה שיש בה כרת ומי עדיפא זו ממצה שאין יוצאין ידי חובת מצה במצה של איסור כמבואר בפ"ב דפסחים וברמב"ם פ"ו מחמץ ע"ש אך משם אין ראיה דדרשינן זה מקרא מלא תאכל עליו חמץ (ל"ה: ע"ש) והכא כיון שאין דרשא לזה מסברא אמרינן דיוצא בזה מצות יבום וראית הרא"ש הוא ממה שאמרו שם דכשנתחלף לו שפוד של נותר בשפוד של קדשים כשרים ואכלו חייב בקרבן ומחלק בין זה לבעילת יבמתו נדה משום דבנותר לא עביד מצוה כלל אלמא דביבמתו יש עכ"פ מצות יבום ע"ש וגם אין לשאול הרי בלולב הגזול פסלינן אפילו ביו"ט שני מטעם מצוה הבאה בעבירה כדאיתא בסוכה (ל.) וה"נ הוה מצוה הבאה בעבירה דכבר כתבו התוס' שם דמצוה הבאה בעבירה לא מקריא אלא כשע"י העבירה נעשית המצוה ואלמלא העבירה לא היתה נעשית המצוה ע"ש והכא גם בלא העבירה היתה נעשית המצוה כשתטהר (וזהו כלולב של אשירה שכתבו התוס' דאין בזה משום מצוה הבאה בעבירה ע"ש):