In the Lord of the Rings in the chapter "The Shadow of the Past", Gandalf explains to Frodo that Gollum was captured and interrogated by the enemy in Mordor. He then explains that later Aragorn captures Gollum after he was captured and held in Mordor. Later in the book it is suggested that Gollum was actually allowed to leave Mordor, but if that is the case, what is the motivation behind Sauron allowing him to leave? How does Sauron benefit from this?
There's not a great deal of information on this in the books. Orcs rescued Gollum from the Elves of Mirkwood, and the Orcs at Cirith Ungol admitted being told to let him go:
'[Gollum]'s been here before. Came out of Lugburz the first time, years ago, and we had word from High Up to let him pass.'
So Sauron presumably did have some plan for him.
We know that Aragorn believes Gollum remains fearful of Sauron:
'There is no doubt that he was tormented, and the fear of Sauron lies black on his heart.'
My personal suspicion was that Sauron knew Gollum's sole aim was to try to obtain the Ring, and Sauron was happy with that. After all, Gollum ventured into Mordor itself for precisely that reason. Sauron probably believed that Gollum was a better option than an Aragorn, Boromir, Elrond or Galadriel taking up the Ring and using it against him - that was always his assumption as to how the Ring would be used.
Gollum would obtain the Ring, hold it, and not use it to overthrow Sauron. Now that Sauron knew the Ring was still in Middle Earth, he could easily use his forces to hunt for Gollum in the types of places Gollum would hide. After all, those are also the places where Sauron's forces tended to reside.
Sauron knew that Gollum would pursue the ring relentlessly, and that this would effectively function as a free service for Sauron. Once Gollum had the Ring it would only be a matter of time until Sauron got it off him as he did not have the strength to bend the ring to his will.
Here Sauron was just playing the long game.
Also, anyone attempting to use the ring to oppose Sauron would also have the loose cannon of Gollum to contend with which would, hopefully, make their job more difficult. Although this does kind of backfire, but only because of special items gifted by the elves otherwise Frodo would have been eaten by a spider.
You are all wrong. I'd have to find the exact reference but in fact Sauron as a wise Maia forsaw his doom when he hurt his hand torturing Golum specifically himself since Gollum had such important information on the whereabouts of the One Ring. That is why he released Gollum out of fear of his doom. Sure Gollum fears Sauron, but more importantly Sauron knows his doom is forever trapped in Gollum's fate. Additonally all the wise (Gandolf, Elrond) all know absolutely Frodo will fail. That is why Gollum is him them and Gandolf cannot forsee Gollum's purpose but has an inkling of it.