By the start of The Two Towers Book Four, Frodo and Sam have not lost their will to continue on with their quest (at least, not yet), but they don't know how to get where they need to go. Enter Gollum: he may not be interested in helping Frodo or destroying the Ring, but he will totally tag along as long as Frodo is the Ring's master. Gollum and Frodo are proof of the old saying that necessity makes strange bedfellows. While Gollum might not be truly committed to Frodo's quest, he is called up by fate (or by Tolkien) to be a part of it.
As Frodo, Sam, and Gollum travel across Mordor, they face hardship after hardship after, well, hardship: the creepy, floating corpse-faces of the Dead Marshes; the huge armies entering the Black Gate to Mordor; the battles between the Southrons and the men of Gondor (between whom Frodo and Sam almost get caught); and the awkward confrontation with Faramir, brother of Boromir, who seems suspicious of Frodo's motives.
Add to these challenges the fact that Frodo and Sam can't trust their own guide, and their journey into Mordor gets even worse. But no matter how much they wish they could just turn back, these are two hobbits with a strong sense of duty: they press on, doing their best to get into the worst place in all of Middle-earth.
Finally, after all of these trials (and Sam's ever-growing suspicion), Gollum leads Sam and Frodo right to Cirith Ungol, the high pass through the mountains that should bring them undetected into Mordor. They climb up and up into the mountains, past the horrible city of the Ringwraiths, Minas Morgul. But just as they are about to enter the tunnel of Torech Ungol (the Spider's Lair), Gollum suddenly disappears. Frodo and Sam have no choice but to enter the dark hole on their own.
What is waiting for Frodo and Sam in Torech Ungol is, of course, Shelob, the giant spider. Shelob is the last obstacle Frodo and Sam have to pass in order to get into Mordor. Sam deals with this arachnid better than Frodo does. Filled with protective fury for Frodo and armed with Galadriel's jewel and his sword, Sam fights off Shelob until she scuttles off, too wounded to keep attacking. Frodo, sadly, just gets poisoned. A roving band of orcs pick up his unconscious body, separating Frodo and Sam for the first time since the beginning of The Lord of the Rings. Uh oh.
All of Book Four of The Two Towers has been geared towards getting Sam and Frodo into Mordor. Now that they have passed through Cirith Ungol (no thanks to their traitorous guide, Gollum) they have finally made it into Mordor. But what good has it done them? Frodo is poisoned, unconscious, and an orc captive. Sam is on his own with the Ring and Sting, trying to figure out a way to rescue Frodo from the orc tower where he is being held prisoner. We have to wait for The Return of the King to find out how Tolkien plans to resolve these obstacles.