In the time of the book of Judges, everyone does what is right in their own eyes. The performance of the judges themselves also leaves much to be desired. Yet also at that time the LORD unobtrusively proves His mercy and faithfulness to the covenant with Israel.
The family of Elimelech ('my God is king') has left Bethlehem ('house of bread') for the pagan Moab because of famine. The hunger was a sign of the covenant curse. (Deuteronomy 28,29,30)
When Naomi is left alone in Moab after a while, she hears that the LORD is giving his people bread again. Verse 6. Then she gets courage to return to Bethlehem, together with her daughters-in-law, who are also widows. On the way, however, Naomi tries to persuade Ruth and Orpah to return to Moab. Orpah yields to Naomi's words, but Ruth impressively swears allegiance to Naomi and to the LORD.
The Holy Spirit put faith in and love for the God of Israel in Ruth's heart. As happened before with Rahab. (Joshua 2 and 6)
The originally pagan Ruth is welcome, and may share in the grace, the salvation of Israel's God. Psalm 87 verse 5,6:
5 ‘And of Zion it shall be said,
“This one and that one were born in her”;
for the Most High himself will establish her.
6
The Lord records as he registers the peoples,
“This one was born there.”
There was enmity between Israel and Moab. Deuteronomy 23 verses 3 to 6.
Moabite men were barred from full citizenship of Israel. However, an Israelite may marry a Moabite woman, as Boaz does. Ruth 4.
Ruth's choice later proves to be of great significance in preparing for the arrival of the "man after God's own heart," King David. For Boaz son of Rahab and Salmon (descendant of Judah) begets a son with Ruth; Obed. Obed becomes David's grandfather. Thus Ruth the Moabite becomes the foremother of the great Son of David; Jesus. See Matthew 1.
He is the perfectly righteous Judge, King, Messiah.