Hello @Pan123,
thank you for sharing the question with the community.
The question your friends is facing is dealt with under § 4StAG:
according to this law: if it is certified that he is the father of the child in question- than he is eligible to apply for an Aufenthaltserlaubnis.
As he is a Student I assume he has a Studentvisa- so in that case he and his Girlfriend should seek a consultation by one of the organisations offering it for free and then they might need a lawyer who can process the application.
I hope I could assist you with the guidance. If there any further question, please do not hesitate to contact us.
Best regards,
Nilab