What role do death and defeat play in the story? What point is being made by the fact that even Beowulf, this great hero, has to die?
Death plays a prominent role in Beowulf because it is an acknowledged fact of life. There are themes that relate to the ancient, pagan, warrior society that praised courage and virtue in battle. If one fought courageously, death in battle (with other tribes or monsters in this case) was a glorious one. In addition to the pagan themes, there is a Christian influence in the text. Wyrd is used in the text and means "fate." This is similar to the notion of God's will. So, death and defeat are celebrated (if done courageously) in the pagan culture and it is acknowledged as part of God's plan in the Christian belief system.
When Beowulf discusses his swimming match, he says, "Fate often saves an undoomed man when his courage is good." In other words, when a man is not totally fated to die (by God or otherwise), his courage can save him. This will serve the courageous man up to a point, but in the end a mortal will have to face death.
Beowulf "has to die" because he is mortal. And in the context of this, as a story, he has to die because death is a precursor to becoming a legend. Since he is such a great warrior, his deeds and his death are all the more glorious, whether from a pagan or a Christian perspective. And this is why the author chose to focus on his life and death. The point is to celebrate Beowulf as a good warrior-king. He must die to become a legend, to become immortal in the sense of his legend being retold for generations as it is in this very text.