The story's setting
Ruth begins by placing its events in the days when the judges led Israel (Ruth 1:1). That was a long and unsettled period before Saul, David, and the later kings. A famine sends Naomi's family from Bethlehem to Moab, where Ruth, a Moabite woman, becomes part of their family.
So the events happened during the time of Judges. Yet the date when those events happened is not necessarily the date when the book was written down. Those are two different questions.
Now it came to pass in the days when the judges ruled, that there was a famine in the land. And a certain man of Beth–lehem–judah went to sojourn in the country of Moab, he, and his wife, and his two sons.
A clue in David's family line
The strongest clue comes at the end. Ruth closes with a genealogy moving from Perez through Boaz and Obed to Jesse and David (Ruth 4:18-22). Since David is named as the culmination of that line, the writer was almost certainly writing after David had entered Israel's public story.
That doesn't give an exact year. It could have been written during David's reign, after his death, or later as Israel preserved and reflected on its Scriptures. The book simply doesn't say who wrote it or when.
And Salmon begat Boaz, and Boaz begat Obed, And Obed begat Jesse, and Jesse begat David.
Why people suggest different dates
Some readers think Ruth was written in or near David's time because its genealogy highlights his family and because it explains an older custom of confirming a land transaction (Ruth 4:7). Others see features that may point to a later period, perhaps when Israel was rebuilding its life after exile. Neither view can be proved from the book alone.
Faithful Christians can hold different views here. The Bible does not ask us to pin down a date it has not supplied. It invites us to notice the story it does supply.
What the book makes clear
Ruth shows God's care in a hard season. Naomi returns to Bethlehem empty and grieving, but Ruth stays with her in costly loyalty. Boaz then acts with generosity and integrity, and their family becomes part of David's line (Ruth 2:11-12; Ruth 4:13-17).
The book's place in the Bible also matters. Matthew includes Ruth in the ancestry of Jesus, alongside Boaz, Obed, Jesse, and David (Matthew 1:5-6). Whether Ruth was written early or late, its message has endured: God works through faithfulness, welcome, grief, and everyday obedience in ways people often cannot see at the time.
So Boaz took Ruth, and she was his wife: and when he went in unto her, the Lord gave her conception, and she bare a son.
