Why was Shaanxi chosen as the capital for many times in ancient times?

Before the Five Dynasties, that is, from ancient times to the Tang Dynasty, many dynasties designated Shaanxi as the capital. At that time, the Loess Plateau was the richest area in China, with lush vegetation, developed agriculture and strong irrigation capacity in the Yellow River basin, so it was always regarded as a treasure of the country. Today, the economically developed southern region was regarded as barren land in ancient times and has not been developed on a large scale.

However, with the development of the times, Shaanxi experienced many large-scale wars, such as the war in which Xiang Yu burned Epang Palace at the end of Qin Dynasty, the war in which Chang 'an was burned in Wei, Jin, Southern and Northern Dynasties, and the war in the end of Tang Dynasty and Five Dynasties. In addition, every time a new dynasty is established, trees must be cut down to build palaces. Vegetation in Shaanxi and Henan suffered a devastating blow, forests gradually died out, land desertification was serious, the Yellow River flooded all the year round, and agriculture withered. Shaanxi has gradually become a poor and backward area. The next Song Dynasty set up Bianjing in the East, and then Yuan, Ming and Qing Dynasties designated it as the capital of the East.