The Two Towers
Shelob means, literally, "female spider." "Lob" is an old word for spider, and "she," of course, means "she." Tolkien also comments, in a letter to Naomi Mitchison on April 25, 1954, that Ungol is Elvish for "spider" (source, pg. 180). Shelob lives under Cirith Ungol: Spider Pass, in Torech Ungol—Shelob's Lair. Once again, this book gives us tons of proof that Tolkien was a huge nerd for languages.
Shelob is an ancient evil so strong that even the light of Galadriel's jewel can only put her off for a time. She is the last child of Ungoliant, also a giant female spider, so it's in her genes to be, well, nasty. She is shaped like a spider, but she has a short neck and a giant, swollen body. Oh, and she also has horns. Yikes.
Sauron knows that she lives in the tunnels leading to Cirith Ungol, but he leaves her there. In fact, he quite likes having such an excellent guard. In fact, he sometimes commands that prisoners be driven into her hole, and he can certainly spare an orc or two to feed her. He calls her his cat, though of course, she in no way belongs to him.
No one knows exactly how Shelob arrived at this particular place near Cirith Ungol, but her kind have been around in Middle-earth since the beginning: Beren fought similar spider-shaped monsters in the Mountains of Terror in Doriath, and so did Lúthien Tinúviel. But Shelob has been in Ephel Dúath since before Sauron laid the first stone of Barad-dûr—that's how old she is. Her descendants have spread all the way into Mirkwood. In fact, Bilbo meets a few of these in his adventures in The Hobbit.
Shelob has spent years and years feeding off men and elves and growing huge and horrifying. All she wants is to eat and eat (and eat). She "only desired death for all others, mind and body, and for herself a glut of life, alone, swollen till the mountains could no longer hold her up" (4.9.53). In other words, Shelob is exactly unlike every single good creature in the novel, in that she in no way craves company. All she wants is to gobble up everything around her—she doesn't need friends or companionship. Friends taste too good to keep around.
Gollum, for creepy reasons of his own, seems to admire this single-mindedness of Shelob, because he actually worships her as a kind of god. After all, Shelob is very powerful, and she has absolutely no interest in the Ring. So Gollum can admire her, be in cahoots with her, and hang onto his Precious, all at the same time.
Gollum's plan is to lead Frodo and Sam to Shelob, wait for her to kill them, and then take the Ring from their remains (ick). Shelob does, of course, attack Frodo and Sam as Gollum expects. The light of Eärendil coming from Galadriel's jewel temporarily pushes Shelob back, but then she takes the opportunity to pounce on Frodo from behind as he is fleeing with Sam towards Cirith Ungol. When Sam sees Frodo unconscious and Shelob about to wrap him up in spider silk, Sam uses an Elvish hymn to freak her out and then he stabs her.
Whether she lives or dies, we do not know, and nor do we really care. The important point is that Shelob, like all evil creatures, cannot stand anything that comes from the elves. Tolkien is giving us further proof that the elves are a force for good in Middle-earth, that they are good by nature, in much the same way that Shelob is bad by nature. Humans and hobbits may be able to pick good or evil, but some of the creatures of Middle-earth just seem to be born that way.
Plus, in terms of the novel itself, Shelob is giving us a good plot reason for Sam to take the Ring from Frodo (who he thinks is dead) before the orcs get him. Without this sequence of events, the orc patrol would have found the hobbits and the Ring for sure. So—thank you, Shelob?