There were different halakhah on marriage, depending on the rabbinical tradition. One may note that Deuteronomy 3:4-5, Ezra 9-10, and Nehemiah 13:23-29 take a strong stand against any intermarriage, whereas the view that ultimately prevailed accommodated intermarriage as long as the spouse converts to Judaism (cf. Kiddishin 3:12 on the status of proselytes as Jews). On this view, David was legitimately Jewish because Ruth was a convert to Judaism (cf. Yevamoth 47b). But one may note that the criterion of matrilineal descent is a relatively late rabbinical view (dependent on an interpretation of grammatical peculiaries in Deuteronomy 3:4-5), and first century AD Jewish sources do not show an awareness of this definition of Jewish identity (cf. Philo of Alexandria, Vita Mosis 1.27.147, 2.36.193, De Tribus Virtutibus 40.224, Josephus, Antiquities 16.225, 18.139, 18.141, 14.121, 14.403, etc.), and of course the two genealogies of Jesus in the NT are patrilineal and trace Jesus' lineage to Judah through male ancestors (Matthew 1:1-16, Luke 3:23-38), and the same is the case with the genealogies of the Chronicler (1 Chronicles 1-9), and in the Torah itself (e.g. Genesis 5, 10-11, etc.).
Neither does the post-exilic book of Ruth specifically claim that Ruth was a Jewish convert, although she is a pious worshipper of Yahweh (Ruth 1:16-17); its primary concern is to show how a Moabite (a traditional enemy of Israel) could be the great-grandmother of Israel's most illustrious king (a tradition that seems to lie behind the obscure statement in 1 Samuel 22:1-4), especially in light of the contrary view in Deuteronomy 23:3 that "no Ammonite or Moabite or any of his descendants may enter the assembly of Yahweh even down to the tenth generation". Thus Ruth aims to confer special blessing on Ruth that excepts her from this rule (see Ruth 2:12).