The last paragraph of Ruth's story is an interesting one. After we read all about the lives of Ruth, Naomi, and Boaz—three random folks from Bethlehem—we get hit with a surprise. This is actually a story about how King David's great-grandparents got together. Yup. We did not see that coming.
There's some debate about whether that genealogy is a later add-on though. Maybe Ruth's story was just a cute little boy-meets-girl tale and some clever person came along and added the whole decedents of King David twist just to make it more interesting, more worthy of reading (source, p. 240).
Or maybe it was tacked on to deliver a message? You know those Moabites you hate so much? Well, one of them was David's great-grandma, so there. Those few little lines might actually be a plea for tolerance. Can't we all just get along… and keep really long, detailed genealogies?