As "punishment" for eavesdropping on Gandalf's conversation with Frodo regarding the dangers of the One Ring, Sam is made Frodo's first companion on his journey to Rivendell in the beginning of The Lord of the Rings. Sam saves Frodo's life more than once during the quest to destroy the Ring, and he accompanies him to the bitter end.
After Shelob attacks and seemingly kills Frodo, Sam takes the Ring intending to complete the quest. Because he holds the Ring for a couple days, he is considered one of the Ring Bearerss. Sam discovers that Frodo is alive in Cirith Ungol and rescues him.
By many people's interpretation, Sam Gamgee was the "true hero" of Tolkien's story: only he is of strong enough will to renounce the Ring of his own free will.
In the 1981 BBC radio serial of The Lord of the Rings, Sam is played by William Nighy. In the movies The Lord of the Rings: The Fellowship of the Ring (2001), The Lord of the Rings: The Two Towers (2002) and The Lord of the Rings: The Return of the King (2003), Sam is played by Sean Astin. It is not clear whether Astin had heard Nighy's radio performance, but both actors bring very similar characterisations (and accents) to the role.