He slays Grendel to save Hrothgar and the Danes.  Grendal is the antagonist in Hrothgar and Beowulf specifically goes there to help, because he is a hero.  Heroes in mythology have the primary goal of obtaining immortality through the one way a mortal can - being remembered for their deeds.