Peter Jackson decided to switch around the book ending to The Two Towers for his Lord of the Rings trilogy. Here's why the changes were made.
In The Lord of the Rings, why does The Two Towers end in a completely different place compared to Tolkien's original book? Broadly speaking, Peter Jackson's The Lord of the Rings trilogy is a faithful big screen representation of the source material, but the director still makes some fairly significant alterations. Entire sections such as encountering Tom Bombadil and the Scouring of the Shire are omitted, while the general tone of the movies is made more accessible and action-orientated for a wider audience. Elsewhere, moments such as Denethor's death are rewritten in ways that shift their original emphasis. One of the biggest book-to-movie changes concerns the ending of The Two Towers.
In the 2002 live-action version of The Two Towers, an alliance of men and Elves (the pointy-eared allies themselves were added just for the movie) overcome the Uruk-hai forces at Helm's Deep, with Gandalf making the last minute save. Elsewhere, Frodo Baggins and Samwise Gamgee convince Faramir to let them continue on their mission and move forward with Gollum as their Mordor tour guide. The imp-like creature ominously hints that he intends to betray the Hobbits by leading them to "her." In Tolkien's The Two Towers novel, Gandalf leads a party to Isengard where he has Saruman imprisoned before riding off to Gondor with Pippin in tow. The trio of Frodo, Sam and Gollum discover "her" is Shelob, a massive ancient spider who seemingly kills Frodo with her sting. Sam fights off the beast using the Phial of Galadriel and takes the burden of the ring for himself, only to later realize Frodo is merely paralyzed and has been taken by Orcs.
Both of these sequences were filmed for The Return of the King, rather than The Two Towers. The Tower of Orthanc material added a death scene for Saruman but was ultimately cut, much to Christopher Lee's chagrin. The Shelob scenes were retained, appearing at the beginning of the final film, rather than the end of the second.