If they did spend time as peasants and commoners how did their experience mark them and their rule?
Im not asking for people who rose through the class structure or illegitimate children, but rather for people who were born into the line of succession.
Similarly people who were banished to another court don't count
I can only think of one example that may fit this highly particular mould: William the Conqueror, born 1028/1029 AD. Before I go any further, I need to note that my focus is medieval Europe, the Middle East, and North Africa with a non-comprehensive smattering outside of that scope - so there could well be other examples I am not aware of. Regardless, I believe it can be safely said that such a particular circumstance as described by the asker is not just uncommon - it is vanishingly rare. Even William may not suite as primary sources regarding their minority are quite limited, with the narrative I am going to present for their childhood being just one of many that have been proposed by historians.
My Sources are "William the Conqueror" by David Bates (both 1989 and 2016) and "William the Conqueror: The Norman Impact Upon England" by David C. Douglas (1964).
William was the illegitimate child of Duke Robert I of Normandy and a peasant woman who we don't really know anything certain about. Different chroniclers have given her different names - but the most common choice is that of Herleva of Falaise. She was probably either the daughter of a tanner, leatherworker, embalmer, or undertaker - roles that were not considered particularly flattering in most medieval communities. As such, being brought into the home of a Duke, even as a concubine, would have been quite the advancement - especially seeing as she would be the mother of the Duke's only heir, our William. She would later be properly married by Robert to one of Robert's knights and her children from that marriage would go on to be of great help to William, but that's another story. As a favoured concubine, Herleva had access to Robert's household - access that would only increase when she would be married into the court later.
"Little is known of William's childhood, and it must be presumed that it was passed in the obscurity of his mother's home at Falaise. Later, legends inevitably developed that his greatness was immediately recognized, and his future achievements anticipated. But there is no evidence to warrant this supposition. Posterity might dwell on the romantic circumstances of his birth, but sentiment could not alter the facts of the situation nor mask William's essential illegitimacy." David C. Douglas, Part 1 Chapter 2, 1964.
While Douglas's quote implies that William was raised exclusively in Herleva's home, Bates holds the opposite opinion that he was likely intended for a life as an aristocrat – noting that William was regarded with enough legitimacy to be backed shortly after his ascension by the Archbishop of Roen and King Henry I of France. This in spite of the fact that there were other, likely more legitimate, heirs to the Dukedom. It is also worth noting here that some chroniclers would state that William was raised for his entire childhood within the court – and we cannot reject that possibility out of hand.
It is in these tenuous circumstances that Robert would die of an illness whilst on pilgrimage to Jerusalem - leaving our young William as the Duke of Normandy at the age of seven. The exact details of what happened next are not relevant to the question being asked, but to put things simply: the stability of Normandy began to deteriorate rapidly. It is very lucky that young William had powerful allies - but even with those allies - William’s ability to hold on to the throne, or even the continuation of Normandy as a Dukedom, seemed anything but certain.
So here we have a young heir to a Dukedom that likely had a childhood primarily as a young noble but who may have spent time in both court with Robert and at his mother's family home amongst the peasantry. After Robert's death he would transition into being a Duke at a dangerously young age - which is when William really proves his worth as my answer to your question. From Robert’s death in 1035 to the Archbishop of Roen’s death in 1037, William’s position was shaky and weak, but secure. But after the Archbishop’s death William would spend the next 23 years fighting to survive and secure their position. Their childhood would be a chaotic cavalcade of assassination and kidnap attempts, and it is noted in numerous chronicles that his various caretakers and supportive relatives went to great efforts to protect the young William. While many died in the effort, a few caretakers are noted to have found success in hiding William among the peasantry – utilizing his mother’s ties to the undesirable communities of Falaise (tanners and undertakers were not well respected) to hide William for extended periods - perhaps even for years, either continuously or sporadically. We can only surmise William would have had to spend that time living as a peasant, or it wouldn’t have been a very effective way for him to hide.
Notably one of William’s caretakers was his Uncle – Walter. Walter was the one that is most noted to have utilized the tactic of hiding William amongst the peasantry and was recorded as having had to often get up in the middle of the night to grab William from his bed and whisk him to safety. Walter, being William’s mother’s brother, would spend a great deal of time with William, perhaps acting as a font of wisdom and a guide as to how to live amongst the peasantry. A little speculative perhaps, but it’s nice to have an additional parallel to Zuko’s similarly caring uncle, Iroh.
Now the hard part of your question: how William’s experience amongst the peasantry marked him and his rule. Honestly – I can’t entirely answer this in good faith. We just don’t know enough about what occurred whilst William was living amongst the peasantry to speculate as to how the experience may have changed him. We can make some safe assumptions – like that having such an unstable and unsafe childhood would have been traumatic and confusing for a young child… but tying any of their personality traits or attitudes concretely to his time in hiding is beyond my abilities.
What I CAN do is provide a brief summation of the personality that historians currently attribute to William – with all the uncertainty that a millennium of distance grants to such a psychological analysis from the platitudes of chroniclers. I will leave you to draw conclusions and connections where you find them, though I caution you against reaching too strenuously for them: He was likely highly intelligent and ambitious – but also exceptionally ruthless and notably entitled. He had quite an appetite if his corpulence later in life was any indication, and was not inclined to forgiveness. Considering his ability to draw support for risky enterprises, he was probably charismatic and he seems to have been a capable and inspiring military leader.