The reason why Yongzheng burned the Shaolin Temple was because it had produced a Tien-Di Gang, whose primary role was to fight against the Qing Dynasty.
Shaolin Temple is divided into North and South Shaolin, of which the North Shaolin helped Li Shimin to fight in the late Sui Dynasty, and was awarded by Li Shimin, and helped Qi Jiguang to fight against Japanese invaders in the middle of the Ming Dynasty when Japanese invaders were flooding the area, and also received praise from the Emperor Wanli at that time.
And Southern Shaolin. At the end of the Song Dynasty, it helped Yue Fei to resist the invasion of the Yuan Dynasty, and also helped the government to fight against the Japanese invaders, as did the Northern Shaolin, but at the end of the Ming Dynasty and the beginning of the Qing Dynasty, it established the Tiandihui (Heaven and Earth Society), which set off a wave of violent anti-Qing and reclaiming of Ming Dynasty movement in the society and triggered the social turmoil.
So what the Shaolin Temple did in the early Qing Dynasty had already shaken the rule of the Qing rulers and was not conducive to social stability, so Emperor Yongzheng decreed that all 25 rooms of the Shaolin Temple should be burned down, and all the monks should be driven to work as farmers in what was then a major agricultural province.
In fact, religious issues have always had a prominent influence in the change of dynasties. Since the introduction of a large number of foreign Buddhists in the Tang and Song dynasties, monasteries around the world have become places of refuge for lawbreakers. A large number of socially unstable and idle people have gone to the Shaolin temples for refuge and to carry out lawless activities in the name of religion.
Because the temple has a large number of social loafers, no help to society, the monks, they get together, they think of rebellion, destabilizing things, so the Kangxi Emperor ordered the Shaolin Temple burned down is understandable, after all, it shook the rule of the feudal rulers.
While movies and TV dramas now treat the Tien-Di Association as a righteous anti-Qing and Ming restoration activity, for the people at the time, it undoubtedly undermined the environment in which they lived and worked in peace and happiness.