Tolkien, who wrote LotR, filled the book with a lot of Christian (Catholic) images. The threesome of Sam, Frodo and Gollum, who take the ring to Mordor, represent the three "parts" of man - spirit, soul and body. The Ring represents sin.
Frodo, who is the soul or mind, is the one who carries the ring. That is because that is where all moral decisions are made. So the soul bears the responibility of dealing with sin. Gollum, as the body, is totally corrupted by the Ring. And in the end is destroyed by it. Sam, represents the spirit. That is why he is able to handle the Ring, and then return it to Frodo without being corrupted. The reborn human spirit is not tempted by evil, nor will it sin.
Sam and Gollum are always in conflict with each other, just as the spirit and the body of most people are in conflict with each other. Poor Frodo, the mind or soul, is caught between them. Having to make compromises to bring the "body/Gollum" along, because he can not live with it. But wanted to be free of the influence of both Gollum and the Ring.
In the end, is the "Sword of the Spirit" (in Sam's hand) that cuts away the Ring, and the last of the flesh that still clung to it, and free Frodo from the influence of evil.