It seems like such a common trope in movies and plays and books, but has it ever actually happened? I can imagine it likeliest in small settings, like tribes or village fiefdoms, but are there notable instances of it happening on the scale of, say, a medieval nation, or a city-state?
Depending on how you define "avenged" and "reclaimed", the restoration of the Monarchy under King Charles II certainly fits the bill.
Charles II's father, Charles I of House Stuart, ascended the throne in 1625, ruling until his execution in 1649. Much of Charles' reign was characterized by quarrel with the Parliament. During this time, European monarchies were moving away from decentralized-feudally-structured systems towards increasingly centralized absolute monarchies, and Charles I, believing in his divine right to rule desired much the same. English monarchs, for a few reasons, could/did not achieve the same degree of authority as did, for example, their Russian or French counterparts, but that did not stop Charles I's consistent efforts towards limiting and ignoring Parliamentary authority. This was particularly relevant in his unpopular wars with France and Spain; war is expensive, Charles I needed considerable supplies, Parliament did not consistently grant him adequate "tunnage and poundage", so he took what was needed and, on more than one occasion, dissolved Parliament. Additionally, Charles I's marriage to a Catholic, his support for high church ecclesiastics in Anglicanism (which by some was seen as back slipping towards Catholic "popery"), and lack of support for Protestants in continental conflicts, further made him unpopular.
In brief, these transgressions led to the English Civil War, with the Parliamentary New Model Army eventually beating the Royalist forces, executing Charles I, and establishing the Commonwealth of England. As is not uncommon in these affairs, the resulting government was little, if at all, better than its predecessor, conflict did not magically cease, and the lives of citizens - nobles and commoners alike - were subject to greater instability.
Accordingly, in April, 1660, General George Monck, 1st Duke of Albemarle, and arguably the single most powerful individual in the nation following Oliver Cromwell's death, wrote to Charles II (at the time exiled in continental Europe) requesting his return to England and the throne. Monck wrote of the "sad and lamentable" condition of Britain, remarking that the revolutionaries hated the name of the king, but "joyfully embrace[d] the power thereof." He states that he and the nation desired a restoration of the monarchy and Charles II's return, but, under three conditions which would be essential to the success of their venture. One, respect the ownership and rights of land acquired lawfully in his absence. Two, spare the lives of those who worked to usurp him and his father so long as they offer their humble submission. Three, to make good on the debts owed to the soldiery, even those who fought against him. Charles II's response was one of measured glee, willfully agreeing to the terms proposed by Monck, thanking him, and speaking to his quick desire to make good on the plan.
Charles II would eventually return, be crowned king, and oversee the restoration of the monarchy. He was generally true to his word regarding Monck's proposals, though his rule was in no way characterized by a meek overlordship wherein his decisions were thoroughly guided by nobles and advisors. He did well in consolidating his power, disbanding the remnants of Parliamentary forces, establishing an extensive police force the likes of which had never been seen before, and was sometimes abrasive to his opponents in a way not so unlike his father.
So, I would say, yes, kind of. While he maybe did not "avenge" his father with a gory comeuppance, he did reclaim - or reestablish - his kingdom, with the help of existing powers there, reviving his fathers legacy and ensuring the continuation of the British monarchy into the present day.
Revenge comebacks happened all the time in history. The question is how closely you insist on sticking to the stereotypical formula. Let's use Lion King (inspired by Shakespeare's Hamlet which itself is inspired by European legends and history)
Even if we move away from legends or the legendary (like Amleth) or tribal (Genghis Khan's dad was assassinated by the Tartars and he did get his revenge after he grew up, but the Tartars were just another tribe and not ruler of the Mongols), we can still find examples in solidly recorded histories that have elements of the story. Just to give a short list of a few famous examples across the world and eras and note how they fit.
So, really, whether or not history matches fiction more depends on how closely you define a "match".
If we look at your question a little more loosely I think it would be fair to include Edward III on this list.
His father, Edward II, was forced to abdicate the throne by a coalition of rebellious nobles lead by his own wife, queen Isabella, and her lover Roger Mortimer. Edward III was made king in his fathers place at age 14, but remained a figurehead for Mortimer’s government. All the real power lay in the hands of Mortimer and Isabella and Edward was in affect a puppet king.
Edward II was imprisoned and probably murdered on Mortimer’s order. The actual details of his death are sketchy and have been the subject of some very unsavory apocryphal stories over the centuries, but it is fairly certain that he was killed (or allowed to die) at Mortimer’s direction. it is worth mentioning that some credible historians have advanced various theories that Edward II was not actually killed but remained imprisoned on the continent for the duration of his life. This theory, while interesting, is based on some rather thin evidence and frankly makes little sense if we consider Mortimer’s motivations.
At the age of 17 Edward III organized a coup that deposed Mortimer. A group of Edward’s friends (many of whom would go on to be his most trusted generals during the opening stages of the Hundred Years’ War) entered Nottingham castle in armor, under cover of night and arrested Mortimer in his rooms. Edward had Mortimer executed, despite his mother’s requests to spare his life. This began the period of Edward III’s direct rule, the impact of which is still readily tangible in the modern world.
It is also worth saying that Mortimer’s de facto rule was not popular in England, in part due to the abject humiliation he suffered at the hands of the Scots in 1325. By contrast, Edward III is considered to be one of the most successful and important monarchs in English history. His reign had profound impacts of English society, many of which are still present.
Since no one has mentioned him so far as I can see, I will mention Netzahualcoyotl the warrior-poet-architect-overhyped by Fernando Ixtlixochitl-king (Tlatoani) of the alcolhua kingdom of Texcoco. His father, Ixtlilxóchitl Ometochtli was the previous Tlatoani of Texcoco and had defeated the neighboring nation of Azcapotzalco in a previous war (probably gaining suzerainty over them to some degree), but through "treachery and deceit" the Tlatoani of Azcapotzalco, Tezozomoc, a hundred-year-old mummy of a man who was so old he "had to be carried in a basket of cotton to avoid damaging his skin" managed to conspire against Ixtlilxochitl and take Texcoco from him, thus destroying the then ruling Triple Alliance and cementing his rule and the foundation of the Tecpanec Empire.
Ixtlilxochitl meanwhile managed to sneak out of the palace with his family before being assassinated, but their pursuers quickly caught up, to save Netzahualcoyotl his family then hid him on top of a tree and allowed themselves to be killed so that Netzahualcoyotl could remain hidden and avoid capture.
Reportedly he spent the next 10 or so years running away, joining a foreign army, escaping, building alliances, gaining political favor and even at one point outright sneaking alone into the Azcapotzalcan palace to declare his defiance to the Huey Tlatoani of the Tecpanec Empire himself and managing to escape once again outside the city.
By this point Tezozomoc himself dies and Maxtla takes his place, -both of them, of course, being depicted as terrible tyrants in later Aztec historiography- and through a series of convoluted events orders the assassination of the then reigning tlatoani of the Mexica, Chimalpopoca (uncle of Netzahualcoyotl), galvanizing an alliance led by Netzahualcoyotl which included the Tlaxcaltecans and the Mexica.
The war starts and goes as well as one could expect considering the Tecpanec Empire heavily outnumbered the enemy alliance but it is at this point that the Tlaxcatecans betray Netzahualcoyotl and refuse to go with him to assault Azcapotzalco, this will grant them a universal fame as cowards and would be the beginning of their feud with the Mexicas, it also means that Netzahualcoyotl's forces are delayed forcing the Mexicans to face Azcapotzalco alone, fortunately for them in the nick of time Tlacopan princes arrived to reinforce them and they defeated the Tecpanec Empire taking its place and reforming a new Triple Alliance.
The delay the Tlaxcaltecans caused did mean that it was technically the Mexicas and the Tlacopans who defeated the Tecpanec Empire, earning the Mexicas a position of primacy in the new Alliance and relegating Texococo and Tlacopa to a kind of secondary status but it also meant that Netzahualcoyotl avenged his family and recovered Texococo from the evil tyrannical ways of centralized Tecpanecan rulership and his descendants would intermingle with the Mexicans and would rule Texcoco for a good while.
Noticed u/ParallelPain mentioned Emperor Wen 汉文帝, so I'll offer up Emperor Xuan 汉宣帝 as an example instead.
So years after the events of Emperor Wen, his son Liu Che 刘彻 (Emperor Wu 汉武帝) was ruling the kingdom. In his old age, he started to become more and more superstitious, which culminated in the witchcraft accusations against the Crown Prince Ju 刘据. Instead of investigating into the matter, he falsely believed his ministers and ordered for the arrest of the Crown Prince. In the resulting revolt, the Empress Wei 卫子夫 and the Crown Prince both committed suicide, and all related family members were murdered, with the sole exception of Liu Bingyi 刘病已 (the baby grandson of the Crown Prince) who was thrown into prison instead.
With his parents and paternal grandparents all dead, the baby only survived due to a prison warden's pity. Bing Ji 丙吉 was aware of his plight and assigned two female prisoners to serve as wet nurses to Liu Bingyi, and once again defended him when further superstitions threatened his life. Some magic practitioners claimed there was a royal aura over the prision, and Emperor Wu ordered all the prisoners to be killed. Bing Ji defied the orders, stating that prisoners should not be killed if they were not convicted of a capital crime, much less the innocent great-grandson of the emperor himself. When Bing Ji's response was related to the emperor, he finally rescinded the order.
Years after growing up in prison, Bing Ji finally located Liu Bingyi's maternal grandmother and he was transferred to her care. He then grew up as a commoner until things changed in the capital.
Emperor Wu had passed away, and gave his throne to his youngest son Liu Fuling 刘弗陵 who became emperor Zhao. When Emperor Zhao too passed 13 years later, the court was in search of someone to takeover as the young emperor (who was only 20 when he died) had not left any heirs. They first installed Liu He 刘贺, one of Emperor Wu's grandsons. When Liu He was deemed unsuitable and deposed just 27 days later, the regent Huo Guang 霍光 then set his sights on 17 year old Liu Bingyi.
After Liu Bingyi was appointed as emperor, he restored the royal titles to his grandparents and parents posthumously. And although the actual perpetrators of the death of his family members had already been executed, Liu Bingyi's reign as emperor was famous for appointing honest and just officials and reforming the judicial system to ensure that any accusations always underwent proper process and did not result in the murder of innocents.
I think Volodymyr (or Vladimir) the Great of Kyivan Rus' would serve as an illustrative example of a story with long historical memory that reveals a more complex truth - perfect when we're talking about tropes!
Volodymyr's father, Sviatoslav, was a staunch pagan conqueror. He fought many battles in the south and east of modern day Ukraine, defeating opponents like the Bulgars and Khazars and expanding the lands of Kyivan Rus' massively. He even campaigned against the Byzantines, who were responsible for his eventual demise. At the ripe age of 29 he was killed in an ambush by Byzantine allies and supposedly his head was made into a drinking cup.
Sviatoslav left behind three sons, Oleg, Yaropolk, and Volodymyr, and a less than clear succession. He left Kyiv itself to Yaropolk, but soon enough Yaropolk and Oleg were feuding amongst themselves, started when Oleg killed the son of a general of Yaropolk's. Eventually Yaropolk went to war with Oleg, and Oleg was killed during the resulting retreat (he unceremoniously fell off a bridge into a ditch and was crushed by the horses of his own army).
Volodymyr was ruling in Novgorod at this time. Seeing Yaropolk defeat their brother, he decided to get the hell out of dodge and fled Rus' for their ancestral homeland, which was, of course, Scandinavia! While there were many nomadic tribes living in the steppes of Ukraine and western Russia, the permanent settlements of the Dnieper river, including Kyiv, were in fact founded by entrepreneurial Vikings (also known as Varangians) looking for a water trade route to Constantinople.
Now in Sweden, Volodymyr assembled a host of Varangians and returned to Rus' to retake it. He successfully sieged down Yaropolk and forced him to the negotiating table. This was only a deception, however, as Volodymyr had convinced Yaropolk's general, Blud, to betray Yaropolk by telling him to go meet with his brother. Yaropolk did so, Blud locked him in, and two Varangians stabbed him through the heart.
Volodymyr became the sole ruler of Rus' and for the next 30 years solidified it into a powerful state. He also converted to Christianity, beginning the generations long Christianization of Rus'. he was not the first Christian ruler of Rus' however; that distinction goes to his grandmother, Olga. Nor was he particularly religious. Indeed, Volodymyr courted representatives of Catholicism, Eastern Orthodox, and Islam - his conversion to Orthodoxy was much a political decision as a spiritual one.
Though he died in 1015, the memory of Volodymyr has persisted for over a thousand years. He is a near mythical character in the nation founding myths of Ukraine, Russia, and Belarus. If you were to summarize Volodymyr's origins in a few sentences, he appears to be a conquering angel, triumphantly returning to his home to overthrow his brother's unjust reign. A very slightly more detailed reading, however, reveals that he was just as politicking as the other members of his dynasty. His story contains all the complexity and moral ambiguity of medieval ruling family struggles in Europe, and yet the passing of time has smoothed over these rough edges and St Volodymyr exists as a paternal figure in the consciousness of multiple nations today. It is telling that the current leaders of Ukraine and Russia are named Volodymyr and Vladimir, respectively.