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.