In epic poems if the Anglo/Saxon and Medieval eras, stories of great men and battles were never written down; nobody could write except the monks, who write in Latin, a language that only the monks could read. Instead these stories were told via song. This is called the oral tradition. These songs were passed down orally from generation to generation both as a means of entertainment and as a means of preserving history.
In Beowulf, the lineage of Hrothgar, and Beowulf for that matter, is given first as a means of respect. It shows homage to one's family, which is expected as a means of remembrance and thanks.
Second, Hrothgar's right to be king must be established. Clearly he comes from a line of capable kings, so Grendel's attacks are not the result of Hrothgar's weakness, but something else.
Finally, Hrothgar's impressive lineage serves to highlight Beowulf's bravery and skill. If the great Hrothgar cannot defeat this monster, how can a man with only 14 men? This allows for the reader to establish Beowulf as a hero.