The below backstory is relayed in the intro of the game
Many years ago, the Gerudo were dragged into a war with the rest of Hyrule by their King Ganondorf’s obsession to obtain the legendary Triforce.
Ganondorf plunged the land toward darkness and ruin. But as Hyrule teetered on the brink of collapse, the evil King was defeated, the Triforce united, and he was sealed away into a realm of darkness.
Following his defeat, his people, the Gerudo were exiled into the harsh wasteland of the desert, guarded so no Gerudo King could again wage war on the peaceful land of Hyrule.
In the absence of war, Hyrule prospered. The King gained respect with the defeat and exile of the Gerudo, and the Royal Family steadily gained power and wealth.
Many years later, a Gerudo King again appeared from the desert sands. Arriving in Hyrule, he was greeted by the Royal Family’s strongest warriors- but he carried no sword or, it would seem, darkness in his heart.
The new king claimed he’d learned from his ancestors’ mistakes. If his people were to survive, it was time for them to mend their relations with the people of Hyrule.
It was unclear whether the Royalty was more interested in his message or in the marvelous gifts he brought from the dusty lands. But they agreed to hear him.
The camera begins at the grandeur of Hyrule Castle with the Gerudo king (as shown in the prologue) on a balcony, then scrolls down the main avenue for a small ways before moving to the slums. It scrolls up the road to the squalor of the Thieves’ Hideout. Link is asleep in his bed, as per Zelda requirements to have Link asleep at the beginning of the games.
Getting up, Link encounters Farin, his gang’s mentor and father figure. Farin says that Anton is waiting outside, and he’s going to test Link on the thief skills Link’s been learning. Outside, Anton meets Link and, in the area around their hideout, has Link follow him up climbable walls, walk along tightropes, slide along narrow ledges, and hide in barrels. He tries to show Link the barrel ambush where you break the barrel in a spin attack, but Link merely clunks around. Anton says it’s okay, they can practice, when Link’s rival, Sykes, shows up.
Sykes takes the barrel ambush failure as an opportunity to again taunt Link, challenging him to steal things using the pick pocketing technique, recalling that this is something Link has always had trouble with. They go to a square in Old Town and Link manages to steal something from a vendor’s stall, but Link is caught when he tries to pickpocket a rich citizen. Sykes quickly abandons Link, who tries to make it back to their hideout.
The streets are unusually chaotic, with guards everywhere, but Link quickly realizes they are not looking for him. He overhears that Princess Zelda has disappeared on an official visit to Castle Town and the guards are searching everywhere. Entering the slums, he bumps into the princess, who ducked out of the procession, horrified to discover so poor a part of her families' kingdom could exist.
They talk a while, the gracious young princess seems determined to help the poor folk. The Gerudo are suffering in the desert- but how can they hope to reconcile themselves with the Gerudo when the same injustice occurs on their own doorsteps?
Just then the guards arrive, closely followed by the rich citizen who relays the story of Link's crime. He concludes that Link must have also been trying to kidnap the princess. Despite Zelda's protests, Link is thrown in jail.
That night, the celebrated Gerudo king turns up unannounced at the jailhouse and bargains with the guard for Link's release. Unsure of his reasons, but glad to be free, Link goes with him.
The king talks of his people, the Gerudo thieves; how their history of evil kings has caused prejudice and discrimination, and how they’ve been exiled to the harsh desert, burdened not only with the unforgiving climate but also hard taxes and trade embargos. He confides in Link how he hopes to reconcile them with the rest of Hyrule on this diplomatic trip.
- (we need him to indicate that he is not Ganondorf, but supposedly a new Gerudo king who isn’t evil. But srsly it is Ganondorf.)
He tells Link that he heard talk in the royal court of his misadventures and has a proposition for him. This noble gentleman rogue is looking for an apprentice: a naturally gifted thief to pass his skills and his legacy down to. He would treat him like his own son, and be the father to him that neither of them ever had.
Link is tempted by the prospect of living like a prince instead of a pauper, and the chance to learn from a master thief, and a Gerudo no less - that would show Sykes - but he remembers he already has a surrogate family, and reluctantly declines the king's offer. The noble thief is saddened by Link's decision but tells him he admires his loyalty to his friends. Link leaves to go back to the gang's hideout.
He arrives at the hideout to find Farin missing. Sykes tells Link that Farin went to find Link and has been arrested. Link must have turned him in for his own freedom! The rest of the children are intimidated into playing along with the older kid's story and they decide to kick Link out of the gang.
Feeling hurt, angry and rejected, Link returns to the gentleman thief's quarters and accepts his offer of an apprenticeship.
First thing the next morning Link is sent on an errand. He is to take a voucher to town to pick up some new clothes, befitting of a gentleman thief's apprentice. Link picks up a finely tailored green tunic and cap, and changes out of his dirty rags. Before he can leave, the shopkeeper asks him to step into a back room, where there is one last article for his outfit. The shopkeeper hands him some dusty bracers, telling Link he's glad to have these filthy things out of his shop, and sends Link back to his new mentor.
Upon his return Link's new master elaborates on how it is his most fervent wish to see peace restored to Hyrule, but he is beginning to fear it is impossible – although Royal Family was happy enough to welcome him and the gifts he brought from the desert, the Hylian royal family seem as if they will never deign to extend the hand of friendship when it is so easy to let the Gerudo continue to bake in the desert sun. No, if he is to see his wish become a reality he believes there is but one option. He relays to Link a somewhat abbreviated version of the Triforce myth, emphasising its ability to grant the bearer their heart's desire. The king would use it to return peace to Hyrule, to free the oppressed, but the Triforce was long ago sealed away. Locked behind an elaborate clockwork mechanism, the only way to access it is with four cogs, forged for this purpose and imbued with forgotten magic or something. The king had been searching through ancient scrolls in the castle’s library, and believes one cog resides with the Deku tribe.
Link begins to understand what the King expects of him. He is too old to undertake the task himself, but is willing to pass on his considerable thieving skills to Link in return for retrieving the pieces of the puzzle that leads to the Triforce. Enthralled by his new mentor, he leaves Castle Town for the first time in his adventure.
Suspicion and Betrayal
All the while a creeping doubt as to the Gerudo king's true motives begins to nag Link. A disturbing thirst for power is becoming evident in his mentor's eyes. His path crosses with Zelda on a number of occasions and he confides in the princess, who has been haunted by visions of her own. Zelda knows all about the legend of the Triforce and begins to suspect the Gerudo king could actually be after the artifact for the same reasons as the evil Ganondorf...
Once the cogs are collected and in the Gerudo king's possession, Link realises his new mentor is planning to betray him, and the scene is set for a showdown.
Just as Link confronts him, Zelda, by now worried for Link, has brought his old gang (minus his rival) and the battle for Link's allegiance begins.
The leader of the gang reveals that Link's new mentor is, unbeknownst to everyone including the royal family, the evil Ganondorf who has escaped from his banishment in the Sacred Realm, eager to resume his search for the Triforce. He tells Link that he knows all this because he is in fact the true king of the Gerudo, who Ganondorf exiled years ago, and he implores Link to realise that his master was only using him to assemble the cogs.
Ganondorf, manipulative to the last, asks Link who he truly believes. Who will he side with?
After some soul-searching Link accepts that Ganondorf was only using him, and defies his new mentor by siding with his old friends. They are, however, no match for Ganondorf who escapes with the collected cogs.
Zelda realises that now Ganondorf is a trusted confidant of the royal family he has free rein to enter the castle as he pleases. There then follows a desperate race to get to the last dungeon, deep in the bowels of the castle's Temple of Time - the Celestial Clock, where the Triforce sleeps for eternity - before Ganondorf does.
When they get there they find it already open and being plundered. If Ganondorf gets his hands on the Triforce he will become so powerful there will be only one way to stop him... Zelda takes Link to a chamber in the temple which houses the legendary blade, the Master Sword, the weapon used by the hero who originally defeated Ganondorf centuries ago. Pulling the sword from its pedestal Link feels the blood of his ancestors coursing through his veins, and understands his destiny is much greater than that of a petty thief. He takes the sword and rushes into the Celestial Clock...
Inside, he finds himself pursuing a mysterious figure, who appears always one step ahead of him. Eventually Link catches up with him and it is revealed to be his rival, who Ganondorf has recruited to finish the job in Link's place. Link defeats his rival and takes the Lightning Rod, using it to activate parts of the dormant machine, until all the power is flowing into a great door mechanism that opens revealing the Triforce.
Ganondorf steps out of the shadows and explains his entire scheme - mocking Link and offering his thanks, since he could not have gotten this far without tricking him and Zelda into helping him, since their destinies are as inextricably linked to the magical golden triangles as his. Then the epic fight for the Triforce begins.
After a great battle Link has defeated Ganondorf. The gang's leader is reinstated as the king of the Gerudo thieves and together he and Zelda unite their people, the two disparate sides of Castle Town begin to live in harmony, the Triforce sleeps safely once more, and everyone lives happily ever after.