It was only during the 1871 unification of Germany that the newly unified German Reich was first assigned an official capital.
Germany was then occupied by the Allies as the outcome of World War II, and Berlin ceased to be the capital of a sovereign German state.
They feared that since Frankfurt was a major city in its own right, it would ultimately be accepted as a permanent capital and weaken western German support for reunification.
For this reason, the capital was located in the smaller university city of Bonn as a more obviously provisional solution.
Another factor was that Bonn is close to Cologne, the hometown of Germany's first Federal Chancellor, Konrad Adenauer.
East Germany claimed all of Berlin as its capital, although the city as a whole was still legally occupied territory and would remain so for 41 years.