They bring the Orc armies to the battlefield quickly and unseen, and Peter Jackson thought they sounded cool.
Peter Jackson: And of course, what happens at this point, but the secret weapon of the Orcs appears, the tunneling machines of the Orc-world.
Philippa Boyens: The "Were-worms of the Last Desert"
Peter Jackson: The Were-worms appear because what we had to do was to arrive an entire Orc army onto this battlefield very very quickly without our heros looking stupid. Now, having just seen Dain's army coming up over the ridge and arriving to surprise the elves, we can't do that twice, we can't have look at the other ridge and here's another army coming to surprise everyone. You can't do things twice. So we just simply had a situation on our hands where we had to figure out some imaginative or inventive or stupid way of getting the Orc army onto this battlefield really fast.
Philippa Boyens: Arriving unseen
Peter Jackson: And so that was the way we choose to do it. I mean we could have had them parachuting off of bats or something.
Philippa Boyens: Well they do burst forth from under the ground. That's in the book.
Peter Jackson: Well yeah.
Philippa Boyens: You just wanted to do giant Were-worms.
Peter Jackson: Well, yes, I did, yes.
Philippa Boyens: As soon as you knew they existed.
Peter Jackson: Well yeah, no, as soon as you mentioned Were-worms, I thought good were having some of those thank you. We'll have about six of them please. Thank you.
Philippa Boyens: And it also, Bilbo talks about possibly seeing the great Were-worms of the last desert in the book. That was a nice way to actually do it.
The Battle of the Five Armies - Director's Commentary [1:17:32-1:18:58]
The lines Philippa Boyens refers to from the book are these:
As soon as I saw your funny faces on the door-step, I had my doubts. But treat it as the right one. Tell me what you want done, and I will try it, if I have to walk from here to the East of East and fight the wild Were-worms in the Last Desert.
The Hobbit - Chapter 1 - "An Unexpected Party"
Tidings they had gathered in secret ways; and in all the mountains there was a forging and an arming. Then they marched and gathered by hill and valley, going ever by tunnel or under dark, until around and beneath the great mountain Gundabad of the North, where was their capital, a vast host was assembled ready to sweep down in time of storm unawares upon the South.
The Hobbit - Chapter 17 - "The Clouds Burst"
(Fun fact: In the original manuscript the line actually went "if I have to walk from here to the last desert in the East and fight the Wild Wireworms of the Chinese.")