Answer: The Gemara in Masechet Mo’ed Katan (23a) recounts that Yosef the Kohen lost his wife and was left with young children. Yosef indeed married his deceased wife’s sister thirty days later. Similarly, the Talmud Yerushalmi (Yevamot, Chapter 4) recounts that Rabbi Tarfon lost his wife and he was left with young children and he proceeded to marry his deceased wife’s sister thirty days later.
Nevertheless, Rabbeinu Yehuda Ha’Chassid (one of the great Rishonim) warned in his famous will that one should not marry his wife’s sister following his wife’s passing, for there is a danger involved. It would seem based on this that marrying the sister of one’s deceased wife should be prohibited because of the danger this poses.
However, Maran Rabbeinu Ovadia Yosef zt”l writes (in his Yabia Omer, Volume 10, Yoreh De’ah, Chapter 12) that there is room to claim that even Rabbeinu Yehuda Ha’Chassid would maintain that when one’s wife passes on and leaves over young orphans and the possibility and will to marry the wife’s sister exists, it is preferable to do so and there is no concern for danger in this scenario. This idea is based on the Gemara (Yevamot 63b) which states, “Your sons and daughters shall be given to a foreign nation,” this refers to the father’s wife. This means that it is in the best interests of the orphans that their father marries their mother’s sister, for she will have mercy on them and treat them properly as opposed to the father marrying another woman where there is concern that the relationship between the children and their step-mother will not be the best. Thus, in this situation, the father may marry his deceased wife’s sister without any concern.
This is notwithstanding for the opinion of several great Poskim that the will of Rabbeinu Yehuda Ha’Chassid was meant only for his offspring and not for anyone else.
Hagaon Harav Yitzchak Elchanan Spektor zt”l was asked in his Responsa Ein Yitzchak (Chapter 37) about a certain man whose eldest daughter was married with children and whose younger daughter was engaged to be married to a certain young man. Suddenly, between the engagement and the wedding of the younger daughter, the older, married daughter passed away. The younger daughter expressed interest in marrying her brother-in-law and he indeed agreed. Her father had posed the question: Is this grounds enough to break off her younger daughter’s proposed match to the young man or not?
Hagaon Harav Spektor discusses this at length and he concludes that this it is indeed permissible to break off the match in order for the younger daughter to be able to marry her brother-in-law. This would indeed be in the orphans’ best interests, for their aunt would surely treat them better than any other woman. He was not concerned at all about the will of Rabbeinu Yehuda Ha’Chassid in this scenario.
Summary: One may indeed marry one’s deceased wife’s sister, especially when one has young children from his first wife.