In Deut 25:5-6, it starts the lay the foundations of the levirite marriage statute, the purpose of which is to raise up seed in the name of the deceased brother "that his name be not put out of Israel" (KJV). In the Book of Ruth, Ruth calls upon Boaz to fill the role of the go'el, which he does after the nearer of kin refuses, and with that move, redeems the land, marries Ruth, and together they have Obed. Yet in Ruth 4:18-22, and even more distantly done genealogies like Matt 1:5, neither Elimelech or Mahlon are mentioned - their name seems to disappear from Israel. What exactly does Deut 25:6 mean, then, if the children aren't raised in the name of the deceased?
The marriage of Boaz and Ruth was not Levirate marriage. Levirate marriage required a widow to marry her husband's brother, after her husband deceased childless. Both brothers must have the same father, and it did not apply to a brother born after the husband death. Since Boaz was not the brother of Ruth's deceased husband, their marriage was not Levirate marriage. So Obed was still under the genealogy of Boaz.
The obligation of Boaz to Ruth was a guardian-redeemer (vv4:14), the law of guardian-redeemer is in Leviticus 25:25-55.
When the neighbour said Naomi had a son (vv4:17), it didn't mean he was his son, the neighbour meant
He will renew your life and sustain you in your old age. For your daughter-in-law, who loves you and who is better to you than seven sons, has given him birth. (vv4:15 NIV)
I'm going to speculate that the author wrote Ruth specifically because it ties a story of faithfulness during the later period of Judges, which was filled with unfaithfulness, with the ancestry of David. Thus, the author supplied Boaz in the genealogy at the end as David's biological forefather, even though Mahlon was the legal forefather. This tradition was followed in Matthew, perhaps again because both Boaz and Ruth were famous. Again, this is speculation.
The question is "What exactly does Deut 25:6 mean, then, if the children aren't raised in the name of the deceased?" First, let's make sure we have the text at hand:
5 “When brothers reside together and one of them dies and has no son, the wife of the deceased shall not be married outside the family to a stranger. Her husband’s brother shall go in to her, taking her in marriage and performing the duty of a husband’s brother to her, 6 and the firstborn whom she bears shall succeed to the name of the deceased brother, so that his name may not be blotted out of Israel.
I think we can presume that more than one or two such marriages took place that we don't know about. These names too have disappeared. In other words, Ruth's case is by no means the only one where the name of the original husband has been lost. Genealogical records may end, but if the lineage continues, the intent of the law is fulfilled. And of course, the intent of the law may simply not be realized, for example, if in a later generation an only-son dies before marrying, or if he has only daughters. Other Torah laws have intentions that were not fully realized as well.
What Dt. 25 is seeking to prevent is a matter of lineage, not actual names. The fact that a genealogical record disappears does not mean that the lineage ends. Also, a law is not necesssarily a prophecy. What it hopes to achieve does not always become reality.