The government probably knew what was going on and encouraged it.
1) Strategically, it cornered the market and has been able to use that dominance to great geopolitical effect.
2) Economic development: environmental regulation and ‘fair’ competition with foreign firms would’ve held back the industry in China, costing jobs and the bottom line for the Chinese state. The breakneck economic growth has been achieved in large part because the Chinese state put economic development ahead of all other concerns.
3) Internal politics. The basic balance between local and central government since the 1990s were that local governments had to fend for themselves financially, and in return central government wouldn’t bog them down with regulation and oversight. The lack of environmental regulation of what is a nationally and strategically vital industry reflects that balance.
The article mentions that most mining operations were illegal until recently and the Longnan government only managed to shut down the last of them in 2017. Some local officials probably lined their pockets by looking the other way, but the central government likely didn't see any of those profits.
Now that the industry is controlled by state-owned companies, stricter regulations were introduced, which is exactly the opposite of what you'd expect if the government were willing to tolerate the pollution in exchange for profit.