The Return of the King
By now, we all know that Gollum is a sneak who can't be trusted: he does, after all, lead Sam and Frodo to (almost) become spider chow at the end of The Two Towers in an effort to steal the Ring. All of Gollum's significant character development happens in the middle book of the series. By the time we hit The Return of the King, he is pretty much set on the road to evil and nothing can make him turn back.
But Gollum's actions at the Cracks of Mount Doom—where he bites off Frodo's finger in an effort to get the Ring and then falls into the volcano and dies just as he thinks he has regained his Precious—do raise an interesting moral question. Gollum intends to steal the Ring for himself, but he succeeds in destroying it altogether. In a weird way, Gollum achieves what Frodo, who has finally succumbed to the Ring's pull, cannot. But does this mean that Gollum has been saved from all of the bad karma of his evil deeds? After all, he saved the world.
We think it's pretty clear that Gollum isn't redeemed. He may save the world, but it was a total and complete accident. In that moment when he falls into the Cracks of Doom, Gollum becomes a tool of fate. But his last real choice—the thing that matters most ethically—is when he steals the Ring from Frodo for his own gain.
Gollum and Frodo are like moral mirror images of each other: Frodo intends to do good nine-tenths of the time and only messes up right in the middle of Mount Doom, at the tail end of everything. Gollum intends to do evil nine-tenths of the time, and only accidentally does good at the Cracks of Doom. Since most of Frodo's life is good, Frodo becomes a hero. And we may feel kind of sorry for Gollum, twisted as he has been by the Ring. But it's clear that Gollum is the villain here, even if he does accidentally save the world in the end.