So i have always thought that the berlin wall was erected shortly after world wars 2 as a result of the tensions between the west and soviet russia, but ive now found out somewhat unexpectedly that it was constructed in the mid 60s.
So with that in mind what was the lead up, sociopolitical, economical or military to the berlin wall and why?
Edit: bonus question. How did Germany reunite as we know it today?
To begin, the Wall went up in 1961, so early 60s rather than mid. But, to your questions!
The purpose of the Berlin Wall was, officially, to prevent fascists from infiltrating the Eastern Bloc from the west; to this end, the wall was called Antifaschistischer Schutzwall, or “anti-fascist protection wall”, which further means the DDR (East Germany)/Eastern Bloc saw the West/NATO, and the BRD (West Germany) in particular, to be fascist states.
Realistically, it was to prevent the flight of East Germans/other Eastern Bloc citizens from fleeing to the West. Several million East Germans left the DDR for the BRD by way of the West Berlin/East Berlin border. Among other effects, this resulted in a brain-drain in the DDR, something the ruling Socialist Unity Party (SED) wanted to prevent/end. So the causes were largely social and economic in nature, under the guise of a political reason. It became a physical representation, along with the rest of the Inner German Border, of Churchill's term Iron Curtain.
As for your other question, reunification of Germany, it was a culmination of several key events. Gorbachev began new policies in the USSR that led to a warming of relations with the US/NATO at large. These were the famous perestroika and glasnost. Poland’s Solidarity movement had some influence of the softening of the hard-line Communist rule. Also, Hungary’s border opening with Austria had an impact, as thousands of East Germans began leaving for the BRD via this route.
There were peaceful demonstrations against the DDR in 1989, leading up to the (accidental) opening of the Berlin Wall on November 9th, 1989. Leipzig and other cities saw large demos calling for peace with the West, reunification of the two Germanies, and actual democracy (vs. the puppet legislature with its elections that were not open). The regime and military watched the demos closely, as did the world at large, but they never took aggressive action.
When it was decided that the travel restrictions to the BRD would be eased, the famous press conference mistake occurred, where DDR official Günter Schabowski, answering a question from the press, said the border would be opened immediately. The change was meant to take effect a day or so later, but he made a mistake, which was broadcast live to East German televisions via BRD broadcasters (whose signals were available to nearly all of the DDR). Thus, people amassed at the Wall and the border guards ultimately let them pass, starting after 9pm.
This led to a dialogue between the Germanies plus the four occupying powers, the first (and last) free elections in East Germany, the necessary treaties being signed (namely, the 2+4 Treaty), and reunification on October 3rd, 1990.
Granted, the whole process was more complicated than my brief overview, but the bones are there. For further reading, you can try the following:
Sources: