Tokugawa Ieyasu, the great unifier of Japan, became the Shogun (essentially military ruler) of Japan in 1603, three years after his victory in the Battle of Sekighara where he won an absolute victory against his opponents. He served as Shogun for a mere two years before he retired. enthroning his son, Tokugawa Hidetada. This however did not mean that Ieyasu lost power, however. He had been following an old Japanese tradition in fact, which was known as ‘Insei‘ or cloistered rule.
[For further context, read Tokugawa Ieyasu, the glorious son of Japan and Resolution in defeat: The Ieyasu way.]
A statue of Ieyasu in Shizuoka, Japan. Source
Hidetada was Shogun only in name, while Ieyasu continued to be in power, assuming the title of Ogosho (retired shogun). This was meant to serve multiple purposes:
Ieyasu had at least in name, ensured succession of the Shogunate and control over Japan to his son, a competent 26 year old. He was himself 62, and therefore could ensure a smooth transition and build up significant legitimacy for his son’s reign.
Ceding the Shogunate rid him of the ceremonial responsibilities that were attached to the post, therefore freeing him to pursue his own tasks.
He could supervise the construction of the Edo castle, the then largest castle in Japan and today part of the Tokyo Imperial Palace. The castle eventually gave the name for the period of the Tokugawa Shogunate itself. 
What Ieyasu did as Ogosho would be beyond the scope of this article. Rather, we shall concentrate on how he ensured a proper and through succession system to the Shogunate he established.
Ieyasu had two wives, but as was the convention, multiple concubines as well. He had multiple sons and daughters. His first ‘trueborn’ son Matsudaira Nobuyasu or Tokugawa Nobuyasu, had committed seppuku (ritualistic suicide) due to an incident in 1579, when he was merely 20 years old. His second son, Yuki Hideyashu was not favoured by Ieyasu and was later given as an adopted son to Toyotomi Hideyoshi, the previous imperial regent. This adoption in reality was an effort by Hideyoshi to make him an hostage in case Ieyasu ever revolted. Even after Hideyoshi’s death, Hideyashu was not favoured by his father. Rather, he placed his trust on his third son, Tokuguwa Hidetada.
He however, set up three of his sons as daimyo [feudal lords] of certain important regions and designated them as successor house in case the main line established by Hidetada ever becomes heir less. They were the only sons who were allowed to use the ‘Tokugawa’ surname.  All three of these sons were exceptionally young. They were Yoshinao (born in 1600), Yorinobu (born in 1602) and Yorifusa (born in 1603) who established the Owari, Kii and Mito houses. Tokugawa established the lines with his young children other than his elder sons, which in itself is interesting.
The succession lines can clearly be seen here:
Source: Cambridge History of Japan, Volume 4
Ieyasu’s decision to establish these houses was motivated because in 1219, the main line of the Minamoto Shogunate ended. He did not want the same fate to befall his line. Thus the Gosanke were born. They were represented by three wild ginger leaves in a circle, representing the three lines of Tokugawa lineage.
Known as the Tokugawa mon, the symbol can be considered analogous to the heraldry of the west.
The Owari house, though the most senior of the gosanke, did not supply a Shogun. The Kii House on the other hand, supplied six, while the Mitwari house supplied the last Shogun.
The first time the houses were ever required to supply a heir was after the the death of Tokugawa Ietsugu, a seven year old, in 1713. This was Tokugawa Yoshimune from the Kii house. With the Tokugawa hegemony being entrenched for more than a 100 years, the succession from a line other than the main line went over with ease.
Ieyasu’s decision to retire and become Ogosho ensured a proper succession for his son. Hidetada, similarly retired and became Ogosho in 1623, and his son, Tokugawa Iemitsu became the new Shogun. Ieyasu thus displayed foresight that many in Japanese History failed to do. His house was eventually thrown out of power, but that was not due to the lack of a heir.
Now, the discussion about heirs and succession has an interesting context as the Imperial family of Japan is facing a succession crisis of its own. This is because of Japanese Law requires that the Emperor be a male, and the Imperial family not having a male member born in 41 years until the birth of Prince Hisahito, the nephew of the current Emperor through his brother (Speaking of the Emperor, it is no longer Akihito, but Emperor Naruhito, his son). The Japanese Government is now exploring what can be done about succession to the Chrysanthemum Throne. The Imperial House had cadet branches, but they were disinherited during the Occupation of the Islands by the United States. In conclusion, succession is very important if you want to keep your legacy from being tarnished.
 The Edo city is today known as Tokyo, and the reason it is the capital has a lot to do with the Tokugawa centralizing power there. More on the Edo castle and symbolism in a later episode covering the Meji revolution.
 Japanese naming systems, as you could have understood by reading my posts, work the other way around compared to English naming system. Thus ‘Tokugawa Ieyasu’ would be ‘Ieyasu Tokugawa’ in the English system.
 Though speculation is that there were more.