The main purpose of building the Walls of China was to keep both people and territory protected from any kind of invasion.
The Great Walls of China coupled with the Beacon Towers, fortification, passes, etc. instituted a very massive defensive system that provided the Chinese society with a very peaceful and safe environment. There were several states during the autumn and spring period, as well as the Warring States Period, so separate sections were built as a defense system against the nomadic northern tribes.
During the Qin Dynasty, the major role of the wall was to keep the country protected very nomadic tribe. During the reign of the Western Han Emperor Wu, a significant role was played by the wall in providing protection for the main force and also served as a strong military base during the wars. Whenever the country subdued any new region, the Wall was usually extended to strengthen the local army. The Han Dynasty was able to conquer more and more territories in north-western China with the aid of the Great Wall. General Qi Jiguang during the Ming Dynasty fortified the regions from Shanhaiguan Pass all the way to the Juyongguan Pass by constructing some military watchtowers and then qualified soldiers based on their local landform to conquer invasions. Additionally, the Wall stopped the emigration of Chinese citizens.