The construction of the 700-foot Wall is one of Game of Thrones' biggest questions, and there's some uncertainty over what really happened. The Wall was a prominent landmark at the very north of Westeros, intended to keep the White Walkers out of the lands of men, but it was eventually torn down in the season 7 finale.
The Wall was a vast structure made of solid ice that stretched 300 miles across the border Kingdom of the North. It was defended by the Night's Watch, with the order's headquarters located at Castle Black (one of many buildings alongside its base. The top of the Wall contained a number of trenches that were dug out by the Watch for their defense tactics, and there was also a number of tunnels used to get to the other sidr. Beyond the border was the home of the wildings, but that wasn't the main concern of Westeros.
Centuries before the events of Game of Thrones, the First Men descended upon Westeros and clashed with the Children of the Forest. In retaliation, the Children created the Night King, the very first White Walker, to help them against the First Men. The plan backfired when the Night King and his newly formed army of White Walkers brought the Long Night, killing all in their path. The Children of the Forest and the First Men put their differences aside to align in the hopes of pushing back the White Walkers to the northernmost section of Westeros. Bran the Builder then gathered forces and used the power of magic to construct the gigantic ice structure.
King Brandon Stark, aka Bran the Builder, is a major historical figure from the Age of Heroes in Game of Thrones' early history. Not only was he the founder of House Stark but he also served as the first King of the North and the Lord of Winterfell. After the White Walkers were pushed north, Bran enlisted the help of the Children of the Forest and their magic. Legend also claims that Bran forced a number of giants in building the Wall, even against their will. Those trapped beyond the Wall following the construction were then referred to as Free Folk.
However, despite the conventional story being that Bran built the Wall to keep the White Walkers out of Westeros, there's suggestions in George R.R. Martin's A Song of Ice and Fire books that it was the result of a truce with Others and that both sides help with construction to divide the continent. There's even evidence that some members of the Night's Watch used the Wall's many secret passages to sacrifice their young to the White Walkers. While none of this is confirmed in the text, it suggests the books have secrets the HBO show only hinted at.
The Wall stood for over eight millennia but was eventually brought down by the Night King. Having transformed one of Daenerys Targaryen's dragons into a member of his undead army, he led his forces out of the Haunted Forest toward the Wall and broke it down with magical blue fire. The breach allowed the Night King and the wight army to cross the borders and march to Winterfell. Following the attack, the Wall was abandoned, with the Night's Watch becoming the new Free Folk