As it always happens with the great scientific centers, it is a combination of several factors. Money. People (usually governments, sometimes private people) who are willing to spend this money to establish and maintain a scientific center. And their ability to hire the best available people. And to create a good environment for them.
And a long period of development in the conditions of prevailing peace and prosperity.
In the case of Gottingen, it was founded by King George II (of England) who also happened to be the "elector" of the land of Hannover. (This part of Germany belonged to the British crown for long time, I suppose until the unification of Germany). King George and his descendants supported the university with the explicit goal to
"promote the ideas of academic freedom and enlightenment". So probably this was the best such place in Germany before the unification. The other German rulers before the unification probably had less money and/or were less willing to spend it on science.
They managed to get people like Lichtenberg, Schopenhauer, Heine and Grimm brothers, not speaking of Gauss.
Gauss spent there most of his long life, so probably he liked the conditions there:-)
Consult the Wikipedia for a long list of famous people who worked and studied there.
When you have a person like Gauss for a long time, this makes the place even more attractive, both to the best students and best researchers.
So in the next generation they had Riemann and Dirichlet....
Bismark who was a student there, later unified Germany.
And I think he was also interested in maintaining the place.