This tale comes straight from the Grímnismál, The Lay of Grímnir, from the Poetic Edda.
The story begins with two brothers, Agnar and Geirroth, sons of a king from an unnamed region. The two siblings decide to go fishing, but a great storm carries them out into the sea and wrecks their boat on a strange coast, where there they get rescued by an old couple.
Immediately after rescuing the boys, the couple splits the brothers. The woman takes charge of Agnar, who is ten years old and destined to follow his father as king. The man fosters eight-year-old Geirroth and decides to teach him wisdom. The couple are, of course, Frigg and Odin in disguise.
The two young boys spent a single winter in the couple’s care. As the sea grew calm, Odin crafted a boat to ferry them back home. Yet, before their departure, Odin confided a secret to Geirroth in hushed tones.
Upon their return to their homeland's shores, Geirroth swiftly disembarked from the boat. Drawing upon the wisdom imparted by the old man, he cast a curse upon his brother, Agnar, banishing him to a realm of malevolence, then pushed the boat back into the vast sea. He returned to his homeland only to discover that his father had passed away during the winter, and he was now declared the new king.
Years passed, and Odin boasted that while Frigg's chosen one, Agnar, was living in a cave, raising children with a giantess like a savage, his own protege, Geirroth, ruled the kingdom originally destined for his brother.
Odin was trying to prove that he could change fate itself by placing Geirroth on the throne instead of Agnar. Hence, he imparted wisdom to the young boy and shared a secret that would ultimately lead Geirroth to betray his brother. Perhaps at this time the Allfather already knew about the prophecy of Ragnarok, and wanted to test his hand on a smaller thing before trying to change the fate of the cosmos.
Frigg, however, has always been renowned for her foresight, and chose not to unveil to Odin her visions regarding the brothers. To Odin she pointed out Geirroth's miserly rule, where he even flouted the rules of hospitality, allowing guests to starve when he deemed their numbers excessive. She insinuated that while Odin may have altered fate, it was not necessarily for the better.
To prove her wrong, Odin pledged to visit Geirroth in disguise and demonstrate the king's ability to treat guests with proper hospitality, and they placed a wager on the outcome of this visit.
To ensure her plan's success, Frigg dispatched her maidservant, Fula, to warn Geirroth of a perilous sorcerer en route to bewitch him. She described the sorcerer as unmistakable, for no dogs would bark in his presence—a trait common among the Gods, that Frigg cleverly exploited for her scheme.
Geirroth immediately apprehended and began to question the suspicious man. Odin, in the guise of Grimnir, refused to divulge his purpose and endured torture, seated between two searing fires that charred his cloak.
Grimnir endured this ordeal for eight agonizing days, deprived of sustenance and drink, steadfastly maintaining his silence.
Ultimately, Geirroth's own son, named Agnar in a remorseful homage to the betrayed brother, took pity on the suffering man and offered Grimnir a horn of mead.
This moment proved to be Odin's awaited respite. He talked with the boy, revealing the mysteries of the divine realms and the structure of the universe. He also pledged to reward the boy for his compassion and kindness.
When Geirroth came to investigate, Odin unveiled his true identity, rebuking the king for his unbecoming behavior and foretelling his impending demise. Terrified, Geirroth drew his sword, but he stumbled, and the blade twisted in his hand. He fell upon his own weapon, meeting his end.
Geirroth's son, Agnar, was then crowned as king, restoring fate's balance by seating him on the throne. Even after intense labor and suffering, Odin failed to change fate, and someone named Agnar still sat on the throne.
Simek, Rudolf. 2007 (1993). Translated by Angela Hall. Dictionary of Northern Mythology. D.S. Brewer. ISBN 0-85991-513-1
Jesse Byock (2005) Snorri Sturluson, The Prose Edda. 1st. edition. London, England: Penguin Books Ltd. ISBN-13 978-0-140-44755-2
Faulkes, Anthony. Edda. Trans. 1982. Oxford University Press. ISBN-13: 9781389651922
Sagas of the Norsemen: Viking and German Myth. Myth & Mankind, Vol. 5, No. 20. ISBN-10 0705435334