King Redeemer of the Kinsmen Redeemer (Matthew 1:18-2:12)

Joseph considers his legal recourse regarding his pregnant fiancé. He thinks that she loves another man because Joseph knows that she is not carrying his child, and so Joseph desires to quietly break off their relationship by appealing to Deuteronomy 24. An angel appears to him and reveals that Deuteronomy 24 is not going to be used, but rather Deuteronomy 25. Joseph will be the levirate redeemer establishing the legality of Christ's line. Why is it so important that Joseph takes Mary to be his wife?