There is no single origin for all Japanese yakuza. Rather, yakuza organizations developed from different elements of traditional Japanese society.
Kabuki-Mono
Yakuzas origin can be followed far back as to the year 1612, when men known as kabuki-mono (the crazy ones). Their odd clothing style, the distinct haircuts and bad behavior, longswords quickly got everybody's attention. They were known as masterless samurais, ronin, and several of them began to wander around in Japan as a band of robbers, plundering villages and small cities. Kabuki-mono generally came from shoguns or samurais whom during long peaceful times were forced into unemployment. Almost all yakuza have the same type of background poor, criminals and misfits. The Yakuza became a family for them. They got help with problems, got attention and could feel a certain saftey
Yakuza however not see kabuki-mono as their "ancestors" instead they feel that they are machi-yakko(City servant), Machi-yakko became the people's heroes, praised by the citizens for their help against kabuki-mono. The Machi-yakko were often weaker, far less trained and equipped than kabuki- mono. Therfore they were compared with England's Robin Hood. Kabuki-mono were known for their ruthless behavior and terrorizing all the surrounding areas. They were well known for stabbing people for pleasure. Kabukimono were gave their groups scary names and spoke in vulgar slang.