The Lanfang Republic (蘭芳共和國) was founded in 1777. The Qing Dynasty banned people from leaving China, so how did the republic get its founding citizens? How did it become a tributary state of China if the population broke Chinese law?
Before answering, I noticed you've asked a previous question regarding China and Southeast Asia (re: migrants to British Malaya during 19th century). I do not know your specific level and area of interest, so I'd like to recommend 2 books:
- Victor Purcell, The Chinese in Southeast Asia (Oxford, 1981), reviewed here. This book is slightly outdated (but up your alley on Chinese migrants/sojourners to Nanyang (South Seas)). Nanyang is the historical name given to Southeast Asia by China, especially the insular part. In fact, Nanyang is still used today. The author was a British colonial civil servant in Malaya, now Malaysia, and historian.
- Philip Bowring, "Empire of the Winds: The Global Role of Asia's Great Archipelago" (IB Tauris, 2018). This book is a wide-ranging survey of insular SEA going back to antiquity. The later chapters, 23 and onward, deals with modern Malaysia, incl how the Chinese came to play a role in Borneo. Impressively detailed book, written with some passion. You might have heard of John Bowring, the fourth governor of Hong Kong?
Back to question: How could Lanfang republic exist in 18th century Borneo if Chinese migration was prohibited during Qinq era?
Borneo has a long-standing trading relationship with south China since antiquity, long before the Manchu dyansty came around during mid-17th century. In fact, these Chinese settlers in insular Southeast Asia (of which Borneo is a part of) pre-date Qing by probably about 1,000 years, i.e. have been there since about 7th-8th century CE, if not earlier.
In other words, even before Zheng He's voyages under Ming (1405 to 1433), the Chinese already had business dealings with people of Borneo.
Borneo in the annals of China
In the Song Shu (宋书 Liu Song History Annals), which was edited by Shen Yue (沈约, 441-513) during the Nan/Southern dynasty, are records concerning the Poli nation (婆利国). Liang Shu (梁 书 Liang Dynasty History Annals), Nan Shi (南史 History Annals of the Nan/Southern Dynasty), Bei Shi (北史 Bei/Northern Dynasty History Annals), Sui Shu (隋书 History Annals of the Sui Dynasty), Jiu Tang Shu (History Annals of the Old Tang Dynasty) and Xin Tang Shu (新唐书 History Annals of the New Tang Dynasty) all show records of the arrival of an emissary from the Poli nation to pay tribute to China (进贡). In the Song Shi (宋史 Song Dynasty History Annals), Borneo was called “Boni” (渤尼/渤泥), and in the Ming Shi (明史 History Annals of the Ming Dynasty), Borneo was also most often known as “Boni (浡泥).”
Source: Wan Kong Ann, “Examining the Connection Between Ancient China and Borneo Through Santubong Archaeological Sites” Sino-Platonic Papers, 236 (April 2013)
From here, it was simply a matter of placing Chinese merchants in and around Borneo for business purposes, learn local customs and language, wait out the monsoon winds, etc. In time, this Chinese became localised (known as Peranankan).
So, the republic was not set up by Qing officials but localised Chinese merchants in Borneo. I believe Lanfang was more co-operative (think joint-stock company without the legal recognition/state support) than republic. The localised term is kongsi.