Why does Charlotte the spider die in Charlotte's Web?
Charlotte dies because, as another answer here mentions, her life-cycle as a spider is complete. After making her egg-sac, Charlotte's biological duty has been fulfilled, and she dies.
If we consider the story from a thematic point of view, Charlotte's death perhaps has a more complex meaning. If we think about it as an expression of the "circle of life" idea, there is a certain melancholy or regret that Charlotte, who is beautiful and smart, and who protects and saves Wilbur, nevertheless is condemned to such a short life span. That Wilbur, who is made into a "star" by Charlotte's writing, should endure and Charlotte herself perish is rendered more ironic perhaps when we consider that it is Wilbur, who, as a runt, should have had his life cut short (but for Charlotte's intervention).
On the other hand, it is possible to think about Charlotte's death less as an end than as an expression of the endless renewal of the bonds of love between Wilbur and Charlotte's family, which endures in the form of the many baby spiders that hatch in the spring. Like Wilbur, this new generation of spiders owe their lives to Charlotte, who may be dead but whose spirit nevertheless lives on.
In Charlotte's Web, Charlotte the spider dies because she is old - in spider-years, at least. Most spiders have a very short lifespan. They hatch from eggs in the spring, mature, and then lay their own egg sac in the fall. After laying the egg sac, their life cycle is over and they die. The egg sac waits over winter, and the new baby spiders hatch in the spring.
While Charlotte's lifespan is the most obvious explanation, Charlotte's death in the book serves to move the story along towards its ending. Wilbur discovers that he doesn't need Charlotte in order to survive - that he has what he needs inside of himself. In this way, Charlotte's death actually does better at teaching him that he can survive than her life - it isn't until she is gone that he realizes she was right all along. Finally, it illustrates how someone's life can keep giving even after they are gone. This can be seen in how Wilbur offers friendship to Charlotte's "children" and in how he continues to live life differently even without her there to tell him what to do.
Spiders do not live very long, and Charlotte reaches the end of her life cycle just after creating her eggs and egg sac.
From a dramatic point of view, Charlotte dies to give the book a sad, but useful climax.
Charlotte dies in the end to illustrate the circle of life. Wilbur lived, even though the runt is typically left to die on a farm, yet, after creating life-Charlotte's purpose has been fulfilled.
It illustrates the circle of life. In Judaism, when our loved ones recount their fond memories of us we continue to live. Wilbur tells each new generation of Charlotte's decendants about her life and what she did for him. In that way, lives on.
each time wilbur tells the story of charlotte, he continues to give her life. in such a why we can, if we are lucky, have immortality. charlotte's death, her true death, will come when no one can recall her name, cannot recall her deed(s), when she fades from memory.