It's not only Germany but also Austria and France (until 2004?). The Germany Wegzugsbesteuerung is meant to prevent cases where Germans leave the country for more than seven (or twelve upon request) years, e.g. to Switzerland, sell their Germany company stock and profit from paying a much lower tax or none like in Switzerland. Steuerflucht, tax evasion is prevented with this and there are certainly many who'd other move abroad, sell without taxation and move back again. There a plenty of exceptions though with countries Germany has a Doppelbesteuerungsabkommen (double taxation treaty) with to prevent cases where the individual would have to pay taxes in both countries.
Personally I never heard of this tax before, despite being a German living in Austria, but then: The tax targets wealthy individuals with company holdings trying to evade taxation.
https://de.wikipedia.org/wiki/Wegzugsbesteuerung