Brace yourselves for a Shakespeare reference. If you've ever read Big Willy's Macbeth, maybe the moving forest of Huorns in The Two Towers will ring a bell. There is a scene in Macbeth (Act IV, Scene i, lines 92-4) when the Three Witches warn the main character:
Macbeth shall never vanquish'd be until
Great Birnam wood to high Dunsinane hill
Shall come against him.
In other words, the witches are saying: don't worry, Macbeth, you're fine. You will only be conquered when the Great Birnam Forest walks to Dunsinane Hill. Obviously, since trees don't usually do much marching, Macbeth thinks he's safe. The witches are being tricky, though: the "wood" turns out to be a bunch of soldiers disguising themselves with tree branches as they travel to Dunsinane Hill to defeat Macbeth.
Why are we telling you all this? Well, according to Tolkien, he has always resented the fact that Shakespeare did not bring real trees to war:
[The Ents'] part in the story is due, I think, to my bitter disappointment and disgust from schooldays with the shabby use made in Shakespeare of the coming of 'Great Birnam wood to high Dunsinane hill': I longed to devise a setting in which the trees might really march to war. (Source, pg. 212)
So Tolkien invents the Ents and the Huorns because ever since he was a kid, he wanted to see a book with a real tree army in it—not just a fake tree army, like in Shakespeare. We have to say, it says something about Tolkien's temper—and his self-confidence—that he uses his novel-writing to correct Shakespeare. Really, dude?
Plus, aside from the fact that it points to Tolkien's environmentalist sensibilities (for more on that, see our "Character Analysis" for Saruman), his use of the moving forest tells us one important thing about the coming war: this is a war that will be fought on all fronts in Middle-earth. Quite literally, no one is safe, and everyone—even the trees—must rally behind the cause of defeating Sauron, the Big Bad.