Legend holds that long ago an Itoman landowner, in order to try to emancipate himself from his position of being beholden to his wife and her wealth, borrowed money from a Japanese lord. He was doing fairly well and was approaching prosperity when the samurai returned from Japan to Okinawa and demanded his money back. The man from Itoman was unable to pay and the samurai became furious, demanding the Okinawan's head.
To that, the Okinawan said, "If you cut off my head, you may then have satisfied your ego but it will not get one yen of your money back." On the other hand, if you allow me to continue as I am going, I will be able to give you your money back in a short while. Besides, I shall give you some handsome interest. For whatever it's worth, you get a bit of wisdom which my sage gave me only this morning."
The samurai, still furious, said, "Well, all right, I should lop off your head but I shall listen to you just this one more time. Then your answer is no money, no head.. I give you this one chance. I shall be back in a year for my money."
Meanwhile, the Okinawan, grateful for the chance to go on with his pursuits, said, "For your indulgence now, I pass along this sage advice. Do not under any circumstances act with haste or impetuosity. Pause carefully and think twice, or three times, before you do anything drastic."
The samurai stalked off, boarded his boat and sailed back to Japan. Upon arrival at his home estate, late at night, he entered very quietly wishing not to disturb his wife. In his own bedroom, by the light of his little candle, he could very well see his wife there, safely in bed, and right beside her was a sleeping companion. Angrily, he drew his sword, about to do in the sleeping pair, when from the depths of his memory came the advice from his Itoman debtor. Rather than act in haste, he took the point of his sword and whipped off the covers. Indeed his wife was in bed, and the person whom he thought was a man beside her turned out to be the samurai's own mother!
Awakened by the fuss, she told him that in his absence she had disguised herself as a man, and slept beside the young wife. Thus no nighttime intruder would ever see the wife "alone."
Because the samurai had heeded the Okinawan's advice, he spared himself the anguish of matricide. Feeling completely grateful to the Ryukyuan, he decided to return to Itoman and tell the man he was to be absolved of his debt. Excitedly, at Itoman, he told the story to his debtor, who advised that one of his investments had turned over well and he then had the money ready to pay. "You must keep the money," the samurai insisted. The Okinawan again refused. Finally they agreed, since neither would accept the sum, to use it to build a shrine to the sea god. Thus, the Hakugin-Do shrine came into being - from the independent spirits in the Orient's most unusual village.
Source: Okinawa: a tiger by the tail by M. D. Morris