In the poem 'Elegy Written In A Country Churchyard' the poet Thomas Gray mourns the unremarked passing of the poor. He wonders what gifts and talents they may have had that we'll never know. It is difficult for us in the modern world with its new schools and computers and ethic of 'education for all' to understand that these labourers had no access to formal education. Many, who could have been quite intelligent and curious, went to their graves without ever holding a book in their hands and could not even read or write. Many went to paupers' unmarked graves which didn't even have their names on. Gray compares them to great men of works or learning he has heard of - and Hampden may have been one of these. Along with Cromwell and others he may have been held up to those who actually did have the privilege of access to learning as an example. Another curious point is that, in the part of England where the poem is set - some villages are referred to as 'Hampdens.' (For example...Norton-sub-hampden.) This may be a reference back to early saxon days when 'hamlets' first got their names,some based on 'ham' and 'den' meaning group of dwellings or ridge.
In the stanza that contains the line you mention, Thomas Grey mentions three people, all of whom are famous Englishmen. He mentions Oliver Cromwell, John Milton, and John Hampden.
Hampden is less famous than the other two today, but he was an important figure in English politics in his time. He was born in 1595 and died fighting in the English Civil War in 1643. He was fighting on the side of Cromwell against the forces of the king.
Before his death he was famous as a Parliamentary leader who had tried to resist the power of the King and to defend the people from abuse by the King. (Therefore the line about withstanding the tyrant.)
Gray includes these three figures in the poem as a way of saying that maybe the unknown people buried there could have been as great as the three he mentions.