The Great Wall is the largest building in China, stretching between the mountains and defending the Central Plains Dynasty from the invasion of northern nomads. There is no doubt that the Great Wall is tens of thousands of miles long, but in fact the real length is far more than ten thousand miles, because all the dynasties in Chinese history have built the Great Wall, and the Great Wall of all dynasties has been added together, and its length has long been difficult to estimate. Back to the main topic, when was the first Great Wall in history built?

The definitive answer is the Western Zhou Dynasty. During the Xia and Shang dynasties, because the population density was not so large, a large number of kingdoms were scattered on the land of China, and people lived in the city and defended themselves, so there was no need to build the Great Wall. Later, as the influence of the Orthodox Dynasty in the Central Plains gradually increased, coupled with the gradual expansion of the agricultural civilization away from the city with the increase of population, it gave the northern nomadic peoples the opportunity to plunder. Therefore, it is important to establish city defenses against nomads.
During the Western Zhou Dynasty, in order to defend against the attacks of the northern nomadic people, the Zhou Dynasty built a continuous row of castles "Leh City" as a defense. The matter of the beacon princes that we know is related to these "Leh Cities". Although these castles did not play a role in stopping the nomads, they could also quickly and effectively transmit war information, and the cooperation between the princes could effectively prevent the nomads from further plundering wealth.
In the Spring and Autumn Period and the Warring States Period, in order to compete for hegemony, the nations defended each other, and built the Great Wall on the border according to their respective defensive needs, the earliest building was the "Chu Fang City" in the 7th century BC, and then qi, Han, Wei, Zhao, Yan, Qin, Zhongshan and other large and small princely states successively built the "Great Wall of Mutual Defense of princes" for self-defense.
These Great Walls, distributed within the Chinese Dynasty, could not play a role in defending against nomads. The Great Wall, which played a role in defending against the nomads in the north, was built by the three kingdoms of Qin, Zhao and Yan. The Three Kingdoms and the powerful nomadic Xiongnu in the north were adjacent to each other, and while building the Great Wall of mutual defense between the princes, they also built the "Great Wall of Rejecting Hu" in the north, and almost all subsequent monarchs strengthened and added. At this time, the Characteristics of the Great Wall are different in the east, south, west and north directions, and the length is relatively short, ranging from several hundred kilometers to 1000-2000 kilometers. In order to distinguish it from the Great Wall built by Qin Shi Huang later, historians called it the "Great Wall of Pre-Qin".
In a practical sense, the Western Zhou Dynasty established the first Great Wall in Chinese history. However, according to the style and scale of the modern Great Wall, the pre-Qin Great Wall can be regarded as the prototype of the modern Great Wall, and the Qin Great Wall is the completed version of this prototype. For more than two thousand years, successive dynasties modeled on the Great Wall of Qin built fortifications to resist the invasion of nomadic peoples in the north.
In fact, the Great Wall's defense against nomadic plunder is only one of its roles, and the other is to weaken the nomadic people. A Great Wall of Ten Thousand Miles blocked the economic exchanges between agricultural civilization and nomadic peoples, and strictly controlled the outflow of materials, especially steel. Without the outflow of steel, the number of military equipment of the northern nomads would become scarce, and without military equipment, their combat effectiveness would be much lower. In this way, in the process of frontal combat, the combat effectiveness of nomadic soldiers is always lower than that of the Central Plains soldiers.
However, due to the existence of the Great Wall, the Central Plains Dynasty also lost another important material for combat, that is, the warhorses with strong feet. Without a powerful war horse, the mobility of the army would be greatly reduced. Although the nomadic people lacked combat equipment, their mobility far exceeded that of the Central Plains army, so every time the nomadic people invaded, the Central Plains Dynasty could only be tired of coping, and it was difficult to completely eliminate it.
In any case, the benefits of the existence of the Great Wall far outweigh the disadvantages. In its history of more than two thousand years, it has resisted the invasion of countless northern nomads and laid a stable foundation for the development of Chinese civilization. Without the Great Wall, Chinese civilization would not know how much suffering it would face.