First of all, let's think of a legacy as something that lives on after death. In Beowulf, the idea of a legacy is presented in two ways.
In Anglo-Saxon England, the warrior culture determined much of how people behaved and the customs they followed. One custom, particularly among warriors, was to seek fame that would live on after the warriors themselves had died. This desire to live on in the form of fame probably grew out of pre-Christian religious beliefs that did not include an afterlife.
Beowulf uses the word fame a number of times in the poem. Even as a young man, early in the poem, when he battles Grendel and Grendel's mother, Beowulf is trying to build a legacy of fame—he wants the stories of bravery and skill to live on after his death. He succeeds in building this legacy because he is successful in battle when no one else was, only he could defeat Grendel and Grendel's mother.
His legacy takes a different form near the end of the poem, when a dying Beowulf instructs the faithful Wiglaf:
Have the brave Geats build me a tomb,
When the funeral flames have burned me, and build it
Here, at the water's edge, high
On this spit of land, so sailors can see
This tower, and remember my name, and call it
Beowulf's tower, and boats in the darkness
And mist, crossing the sea, will know it.
Thus, Beowulf will live in not just in the form of stories and memories, but also as a visual symbol from the sea.