We know Sauron intentionally let Gollum go so that Gollum would lead Sauron's minions towards the Ring, and Sauron knew Gollum would look and follow the Ring at all costs. So when Shagrat sees Shelob with her "sneak," why did Sauron order the orcs to let him roam freely whenever he liked, and surely Sauron must have realised that Gollum was actually following the Ring bearer into Mordor.
Sauron appears (though this is never said in so many words) to have released Gollum to allow him to hunt for the Ring, in the hope that he would lead Sauron to it. Shagrat seems to be aware of this intentional release:
He's been here before. Came out of Lugbúrz the first time, years ago, and we had word from High Up to let him pass. He's been up the Stairs once or twice since then, but we've left him alone.
(The Lord of the Rings, Book IV, Chapter 10, "The Choices of Master Samwise")
So Gollum has been up and down into Cirith Ungol previously, even after his release, and Shagrat appears to accept this as nothing out of the ordinary. He certainly doesn't say anything to indicate that he notified (or had orders to notify) "Higher Up" of Gollum's appearances.
To understand why Gollum's reappearance near Mordor wouldn't worry Sauron, remember his arrogance, and his assumption that anyone possessing the Ring would behave as he did and try to use it to control others. Sauron had no clue that the Ringbearer would want, much less try, to destroy the Ring.
In addition, the sighting of Gollum by Shagrat's company occurred "early last night" according to Shagrat; that is, the night before Frodo's capture. According to Appendix B, this in turn occurred on 13 March 3019, so that the sighting must be dated to 12 March. This was well after Aragorn's confrontation with Sauron through the palantír, which occurred on 6 March according to the appendix. Sauron was entirely focused, then, on a possible attack led by the Heir of Isildur and therefore presumably coming from Minas Tirith. If anything, he might be more likely to believe that Aragorn had it than to think that Frodo or Sam might. This belief is reflected in the words of the Mouth of Sauron:
"Dwarf-coat, elf-cloak, blade of the downfallen West, and spy from the little rat-land of the Shire..."
If the Mouth of Sauron believed that Frodo was a spy, presumably Sauron did as well; and if he did, it must be because he never considered the possibility that Frodo might be the Ringbearer, intent on destroying the Ring.
why did Sauron order the orcs to let him roam freely whenever he liked
Gollum is no threat to Sauron, and letting him roam only increases the chances of finding the ring through him. Gollum is clever, sneaky, and relatively knowledgeable. Gollum is trying to find the ring, which increases Sauron's chance to find the ring.
surely Sauron must of realised that Gollum was actually following the ring bearer into Mordor.
It's easy to say from our perspective as the reader, but Sauron never thought that anyone would even consider destroying the ring. It didn't cross his mind for even an instant that the ring bearer was in Mordor with the intent to destroy the ring.
"He is in great fear, not knowing what mighty one may suddenly appear, wielding the Ring, and assailing him with war, seeking to cast him down and take his place.That we should wish to cast him down and have no one in his place is not a thought that occurs to his mind. That we should try to destroy the Ring itself has not yet entered into his darkest dream."
-The Two Towers, "The White Rider"
The last line is the important one here, but the first few are relevant as well because it describes what he can only conceive of the ring. Power. He can only conceive of a being using it for their own power and their own personal gain. To destroy it isn't even on the radar.
There isn't any negative side to letting him walk around, but the positive end of it is he could achieve his ultimate goal.
This is more of a theory than a reference but it still could apply. Gollum was Sauron's Patsy or Pawn\Puppet, and also was his Frankenstein's Monster because of the One Ring that he had also created, and used his fear of him to get him [Gollum] to fulfill his role. The reason behind the torture could have been that Gollum questioned Sauron though Smeagol, in regards to Frodo and Sauron pretty much responded with punishing him - and possibly scaring every nimble bone in his body, in order to get even more control over him though psychological means, thus scarring him.
Sauron was desperate enough to get his ring back from the Hobbits that he would seize any opportunity to do this and maybe this was his way.
And Gollum became more of a monster because of Sauron, and Sauron sadistically did this to get his Ring back, but lost it due to Frodo's free will and willpower to overcome his Ring and destroy it in the fires of Mount Doom. Thus Sauron lost.