The Yakuza evolution is not one of master-less samurai to global criminal organization.
Brief history: The Ashikaga shogunate is the ruler of Japan since 1336 when they overthrew the Kamakura shogunate. They are the undisputed military leaders of Japan until 1477. The shogun Ashikaga Yoshimasa has no son and he adopts his younger brother to become his successor. But then his wife gives birth to Ashikaga Yoshihisa, which leads to a fight between the two brothers about who would become the next Shogun. Yoshimasa wins what would be called the Onin war, but the Ashikaga is so weakened that nobody really listens to them anymore.
For over 125 - until the Tokugawa shogunate is established in 1603 - Japan is involved in a massive civil war. Oda Nobunaga conquers a significant portion of the country before being killed by one of his own men. Toyotomi Hideyoshi takes up the mantle of Nobunaga and unites Japan under his rule and then invades Korea. Twice. He dies and leaves his young son as ruler but Tokugawa Ieyasu seizes control over Japan and creates the Tokugawa shogunate.
The country, which had undergone years of brutal conflict and bloodshed, was now "peaceful". Hatamoto, who were direct vassals of the Tokugawa, eventually moved into bureaucratic positions within the new shogunate. The problem was that there were only a limited number of those positions in the new bureaucracy and there were a lot of samurai who no longer had a war to fight. That's how you got the creation of the hatamoto yakko - also known as the kabukimono.
The hatamoto yakko were like a biker gang. They would head into town, eat a bunch of food and not pay their bill, "test" their new swords on peasants (tsujigiri) and fight other wandering samurai. To guard against the hatamoto yakko, towns created the machi yakko. These were like vigilantes or an auxiliary police force made up of shop keepers, construction workers, clerks, and other random commoners who would protect the town against the hatamoto yakko. And it is these two groups that scholars believe evolved into the yakuza.
But that's wrong.
Goro Fujita, in his history of the Yakuza One Hundred Year History traces the organization back to two separate groups in Japan: the Tekiya and Bakuto.
The Tekyia were like low class merchants. They were itinerant peddlers who travelled the countryside, set up temporary market stalls, and were in charge of security during Shinto festivals. They often sold either illegal, or shoddily made goods. Goro Fujita claims that Tekiya would band together for protection during the early Tokugawa period, and they eventually became fairly influential in Japan. There was a familial relationship among the tekiya with an oyabun (boss) overseeing the kobun (gang members). David Kaplan and Alec Dubro, in their book Yakuza: Japan's Criminal Underworld says that the Tokugawa shogunate "in order to reduce the widespread fraud among tekyia vendors and to prevent future turf wars, appointed a number of oyabun as 'supervisors' and allowed them the dignity of 'a surname and two swords.'"
The Bakuto were gamblers in Japanese society. They ran gambling houses, loan-shark businesses, and provided security. In fact, it is from the Bakuto that you actually get the name Yakuza. 8-9-3 - pronounced yakusa - is the lowest possible hand in the card game Oicho-kabu. That essentially means that the yakuza were calling themselves the lowest of the low. Manabu Miyazaki, a prolific Japanese author whose father was the head of a yakuza gang, says that the Yakuza view themselves as societal outcasts. "Yakuza are dropouts from society. They've suffered, and they're just trying to help other people who are in trouble."
While both the Tekiya and Bakuto were organized during the Edo period - the same time as the hatamoto yakko and machi yakko - they did not have a a history as ronin or master-less samurai.
TL;DR: A romanticized view of the yakuza has them evolving from vigilante groups defending against wandering samurai. In actuality, they evolved from itinerant peddlers and gamblers.