In 164 BC, Emperor Wen of Han Dynasty appointed his younger brother Liu An as the King of Huainan. Liu An liked Taoist priests and often recruited thousands of Taoist priests to work on alchemy in the king's residence. Taoist priests had to use salt brine in alchemy, because by heating salt brine, they got hydrogen chloride, and by combining hydrogen chloride with water, they got hydrochloric acid.
But one of the Taoist priests inadvertently dropped the brine into the soymilk, and to his surprise, the soymilk solidified. This Taoist priest thought that "soy milk is corrupt", but other Taoist priests tasted it and had no adverse reaction afterwards. So it was later named tofu.
Expanded Information
Tofu has a long history of existence, and is said to have been invented in 164 BC by Liu An, the King of Huainan, the grandson of Liu Bang, the first Han emperor of China. Liu An invented tofu by accidentally dotting soybean juice with gypsum while burning medicines and making elixirs on Bagong Mountain, on the border of Shou County and Huainan in Anhui Province.
Yuan Hanqing thought that tofu came into being in the Five Dynasties. Japanese scholars, Shinoda Toho, according to the fifth generation Tao Valley, "Qing Yi Lu" "for the Qingyang Chancellor, clean and diligent people, meat flavor not to give, the day the market tofu a few," that the origin of tofu in the end of the Tang dynasty.
Tofu only became an important food in the Song Dynasty. Southern Song poet Lu You recorded Su Dongpo liked to eat candied tofu gluten; Wu Zimu "Dream Sorghum Records" recorded that the capital city of Lin'an wine store selling tofu and fried tofu.