After his victory at the Battle of Sekigahara in 1600, Tokugawa Ieyasu controlled Japan but did not abolish the roughly 250 Daimyo, the regional lords who governed their own domains and commanded their own Samurai. The Tokugawa Shogunate therefore needed ways to keep these lords, especially former enemies, from combining against it. Alternate attendance, sankin-kotai, was the most effective.
The custom of lords paying court to the ruler was older, but the third shogun, Tokugawa Iemitsu, made it law in 1635 and extended it to all daimyo in 1642. Each lord had to spend alternate years, in most cases, at the shogun's capital of Edo (Tokyo) and at home. When he left Edo, his principal wife and his heir stayed behind in the family's Edo mansion, in effect as hostages. Checkpoints on the main roads watched for 'women going out and guns coming in', the signs of a plot.
The system worked politically and financially. A lord who was away from his domain half the time and whose family was in the shogun's hands was in no position to rebel. The expense was crushing by design: daimyo had to maintain several mansions in Edo with large permanent staffs and travel in processions of hundreds or thousands of retainers whose size displayed their rank. These costs commonly consumed a large share of a domain's income, money that could not be spent on arms.
The unintended effects were just as important. Constant traffic of processions along highways such as the Tokaido supported inns, porters and post towns. Lords had to sell their domains' tax rice for cash, largely through the merchants of Osaka, speeding the growth of a national market and of a wealthy merchant class. Edo swelled to about a million people by the early 1700s, and elites from every province shared a common urban culture. The requirement was relaxed in 1862 as the shogunate weakened, shortly before the Meiji Restoration.
The closest comparison is Louis XIV's Palace of Versailles, where French nobles were likewise drawn to court, kept under observation and encouraged to spend ruinously. Both are examples of monarchs curbing existing elites, as Topic 4.7: Changing Social Hierarchies from 1450 to 1750 describes. The Ottoman Devshirme solved the same problem differently, by creating a new elite rather than taming an old one.