Deuteronomy 25:5-6

5 Perhaps two brothers live together in the same place. One of the brothers may die before he has any son. If that happens, his widow must not marry anyone who does not belong to the family. Instead, the other brother must marry her. That is the right thing for him to do for his dead brother. 6 The first son that the widow gives birth to will be the son of her first husband. His family's name will not disappear from Israel.