At the beginning of Book Six, Prince Charming—oops we mean Sam—manages to rescue Frodo from captivity in the orc watchtower at Cirith Ungol, even though Frodo's hair is nowhere near long enough to reach the ground from such a great height. Unfortunately, Frodo has been forever weakened by the attacks of the orcs and, of course, the monster Shelob in The Two Towers. As they try to slip quietly past the orcs of Mordor, Sam finds himself increasingly responsible for dragging and carrying Frodo as best he can towards Mount Doom. The Ring is draining Frodo so horribly that he has almost no strength left to resist despair.
After this awful, plodding journey through Mordor, Frodo and Sam get to their ultimate vacation destination, Mount Doom. But Frodo has also reached his absolute limit in resisting the Ring. Frodo's amazing willpower takes him into the chambers of Sammath Naur, within the volcano of Mount Doom itself. That's proof right there that Frodo's stubbornness in finishing the quest is amazing. But in the end, it's not the lava that leads him astray. He is ultimately unable to let go of the Ring willingly because of the jewelry's own dark power. Luckily, Gollum is around to bite off Frodo's finger and then stumble and fall into the fiery pit, taking the Ring with him. Thanks, buddy?
But this resolution to the Ring Quest leaves Frodo with two enduring emotional scars. The Ring damaged him while he carried it for all of those miserable months. And, in spite of all of that hard work, Frodo did not actually succeed in his quest in the end. So Frodo has been injured both by the Ring and by his failure to get rid of it at the right time. Bad news all around.
Frodo's deep emotional and physical scars from the quest leave him unable to return to ordinary society, either in Gondor (where he doesn't belong because he's a hobbit) or in the Shire (where he doesn't belong because he's now a weirdo). Sam has also been permanently changed by the quest, but he was a fairly regular hobbit to start with, and he can still blend in with the rest of the Shire. Plus he's got a lady love, which Frodo is sorely lacking.
When Frodo decides that he has been too hurt by the quest to stay in Middle-earth, Sam inherits not only Frodo's home and wealth, but also his legacy as a storyteller and Ring-bearer. Thanks to Sam, the Shire remembers at least something of the great deeds performed by Frodo during the War of the Ring. Frodo saves the Shire from destruction, but it is Sam who takes care of the Shire after it has been saved.