A rōnin is essentially a nomad, drifter or wanderer. In Japanese folklore, a rōnin was a Samurai without a master. His master would have died and the Samurai would become homeless and adrift, never two find a stable home again.
In Japanese art, a rōnin is portrayed as a man who spends his time wandering, usually carrying two swords but not being a danger to anyone but himself.
Samurai are, according to legend, supposed to commit Harakiri, suicide, on the death of his master. This is done with their own hand, and their own sword, when they slice open their heart and belly, with great honour. Those who do not do this, wander. These are the rōnin, the Samurai who never belong again.
Rōnin were depicted in shunga art as lonely and lost, but strong. Sometimes, they turned into criminals, working as bandits or highwaymen. Sometimes they banded together to form their own gangs. They operated in brothels, and a lot of shunga art shows rōnin with women, often taking that which should not be theirs. Some became gang leaders, others worked alone. With time, they became more feared than shunned.
As Japanese folklore changed, so did the rōnin. Whereas Samurai were expected to kill themselves on the death of their master in the early centuries, this changed. With time there were hundreds of rōnin wandering the Japanese landscape. Many have been painted as a form of shunga art.