All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If the only motive behind this marriage is helping this girl to have the right of residence in Germany; then, it is impermissible to have this marriage because it helps her to commit a sin which is staying among the disbelievers without necessity or a valid need under the Sharee‘ah (Islamic law).
The Prophet, sallallaahu ‘alayhi wa sallam, said: “I exonerate myself from every Muslim who lives among the disbelievers.” [At-Tirmithi]
The scholars stated that judging a matter is based on the intention behind it. The Prophet, sallallaahu ‘alayhi wa sallam, said: “Indeed, the deeds are judged according to the intentions, and a person will receive the reward according to his intention.” [Al-Bukhari and Muslim]
So, every deed which is done in order to reach something unlawful is considered unlawful, even if the deed in itself is something permissible.
Allaah Knows best.