The short answer is ‘Never’.
1. Some have argued that once the marriage is consummated the marriage becomes lawful. But this argument seems to have no base in scripture nor does it make sense. God did not join the couple together during the marriage ceremony so why would the consummation, which Jesus calls adultery, act as the trigger for the bestowing of His divine blessing?
2. The death of the first spouse does not make an unlawful marriage lawful. It is true that the couple no longer commit adultery against the former spouse since the former spouse is no longer alive. However the death of a third person is never given in scripture as a reason for God to join two people together as one. Rather, sexual intercourse within this marriage should now be considered fornication. Although the first spouse is no longer alive, the couple are not lawfully married and thus any sexual relations are still outside the God ordained bounds for sexual intercourse
An unlawful marriage always remains unlawful. Simply put, there is no marriage existing which can be made lawful. There is no marriage covenant since God never joined them together. So there is no marriage in any sense that matters.
Thus, the only course available is to repent for pursuing an unlawful marriage and either separate from the unlawful spouse or marry again, this time with God’s blessing.