Hamlet was the same age as the gravedigger's job, which had begun on the very day that Hamlet's father won some land in a duel to the death with Fortinbras' father. Hamlet was heir to that land ("his fell heir to"). Thus, metaphorically, Hamlet was born to be heir to a graveyard ("must the inheritor himself have no more"?).
All that happened about 30 years ago. The "30" is also mentioned in "The Mousetrap," where the Player-King said to his queen, "thirty dozen moons with borrow'd sheen
about the world have times twelve thirties been" since their marriage. This is meant to signal 30 years, thus relating the Player-King to Hamlet's father. (Actually, it would be about a month short of thirty years, but the audience would probably have missed the point if he'd said "forty dozen moons" (Hamlet's age, 30 years plus 10 months). The main significance of "thirty dozen moons" is that it indirectly relates Hamlet (by his age) to the moon, which glows with "borrow'd sheen" - the cause of Hamlet's "lunacy" - his reflection of his father's warmongering, grave-grabbing values.
Hamlet wanted to go "back to school in Wittenberg." That doesn't mean he was a student. At age 30, he may have been a tenured professor. (Did they have tenure in those days? It doesn't matter, they didn't even have a university in Wittenberg in Hamlet's days. It was founded much later, and became famous because Martin Luther taught there. I believe that Shakespeare was Catholic, but the Hamlet-Wittenberg connection indicates that Shakespeare at least respected some aspects of the Reformation.) When he was true to himself, Hamlet just wanted to go back to Wittenberg where, at age 30, he was well-settled. It was his father's ghost and his uncle who were pushing him to inherit that graveyard.
King James VI of Scotland, in his private correspondence, lliked to use code-numbers in case his letters were intercepted. His code for himself was "30." There are many parallels between Hamlet and James VI. (For instance, James was the son-in-law of the King of Denmark, who drank himself to death. At the head of the Danish King's funeral procession marched three Danish courtiers: Rosencrantz, Monk, and Guildenstern.) I believe that James VI wrote the Ur-Hamlet which Shakespeare later "polished" in order to curry favor with the soon-to-be
King James I of England.