(Click the character infographic to download.)
Sam is the world's greatest sidekick. We defy you to find anyone better at kicking sides, seriously. He is absolutely, 100% devoted to Frodo. At the end of The Two Towers, when Frodo has been captured by orcs and Sam is holding the Ring, Sam immediately starts figuring out how to rescue his master. He's got absolute power literally in his hands, and all Sam wants is his friend back, safe and sound. Sometimes it's almost tough to think of Sam as an independent character because his identity is totally bound up in his job of helping Frodo.
But as Sam and Frodo start to trudge through Mordor, Frodo gets weaker and weaker. And Sam has to start taking charge to make up for it. Sam becomes the decision-maker in their duo, because that's what Frodo needs him to do. On the road to Mount Doom, Sam becomes as tough as any Gondorian soldier:
But even as hope died in Sam, or seemed to die, it was turned to a new strength. Sam's plain hobbit-face grew stern, almost grim, as the will hardened in him, and he felt through all his limbs a thrill, as if he was turning into some creature of stone and steel that neither despair nor weariness nor endless barren miles could subdue. (6.3.5-6)
In other words, like Frodo, Sam stops thinking of the end of the Ring Quest. He just knows that he has a duty to just keep going, no matter how difficult it is. Sam is no longer an ordinary hobbit. Even his face has changed to become "stern, almost grim" with his new resolve to continue fighting against huge odds.
We mentioned in Frodo's "Character Analysis" that when Frodo can't walk anymore, he crawls up Mount Doom. Well, when Frodo can't crawl anymore, Sam, that "creature of stone and steel," actually carries the poor guy on his back up the side of the volcano. Like we said: Best. Sidekick. Ever.
All through The Two Towers, Sam was president of the Anti-Gollum Club. He never stopped suspecting Gollum of terrible motives. And he kept egging Frodo on to get rid of Gollum, or at least to stop being so nice to the little sneak. Sam thought Frodo's pity for Gollum was too generous at best, and downright careless at worst (if it's possible for Sam to think so harshly of Frodo).
Well, now we're at The Return of the King, and finally, Sam has learned the moral lesson Frodo has been trying to teach him. Gollum actively attacks the two hobbits on the side of Mount Doom, and Sam fights him off. He has the chance to kill Gollum. But instead of knifing him, Sam thinks:
But deep in his hearth there was something that restrained him: he could not strike this thing lying in the dust, forlorn, ruinous, utterly wretched. He himself, though only for a little while, had borne the Ring, and now dimly he guessed the agony of Gollum's shrivelled mind and body, enslaved to that Ring, unable to find peace or relief ever in life again. (6.3.78)
Sam finally gets what Frodo has been telling him all along: Gollum is loathsome, but he has been made that way through literally centuries of loneliness and misery. And once Sam understands that about Gollum, he just can't kill the little guy. So Sam also shows mercy to Gollum, which leaves Gollum alive long enough to seal his own fate. And isn't that how it should be?
Once Sam wakes up in the Field of Cormallen, he finds out that the Ring has been destroyed and he and Frodo have been saved from certain death in Mount Doom's lava by Gandalf and the Eagles. And does he say something epic and high-minded to celebrate? Nope, not at all.
Sam bursts out, "I feel like spring after winter, and sun on the leaves; and like trumpets and harps and all the songs I have ever heard!" (6.4.31). Sam's excitement still sounds very Sam-like: it's straightforward, not too fancy, and totally heartfelt. So, Reason #1 Sam wins the Ring Quest? Because he doesn't change too much. He's still Sam the Hobbit at heart.
Reason #2 Sam wins the Ring Quest is that he learns the same moral lessons that Frodo learns (though maybe a little more slowly). He shows mercy to Gollum, just like Frodo, and he keeps going with the quest even when he finally realizes that it's impossible. Sam shares Frodo's humility and forgiveness, which are both the qualities we mentioned in Frodo's "Character Analysis" that make Frodo a top-notch Ring-bearer.
But! (And this is the third reason why Sam wins the Ring Quest) Sam doesn't have to undergo the same emotional torture that Frodo experiences as the series' main Ring-bearer. Sam sees Frodo suffering, and he does his best to help. But he doesn't have to live with "the wheel of fire" (6.3.30) that Frodo describes floating in front of his eyes at all times of the day or night.
As Tolkien puts it:
Frodo will naturally become too ennobled and rarefied by the achievement of the great Quest, and will pass West with all the great figures, but S. will settle down to the Shire and gardens and inns. (Source, pg.105.)
Frodo has become something actually, genuinely different from the other hobbits (and maybe from all the other beings in Middle-earth). He has grown rarefied, which means he has become really spiritual or elevated.
On the other hand, Sam has become an outstanding hobbit, but he is still a hobbit. He can still enjoy "the Shire and gardens and inns," while Frodo cannot. It's this essential difference that means Sam can stay in the Shire and inherit Bag End and lead a long and happy life, while Frodo has to find his peace outside of Middle-earth entirely. By the end of The Return of the King, we're glad to see that Sam has a chance to figure out who he is as his own Master of Bag End, without being anybody's servant. He's a sidekick no more.