Dear @JJ061987,
Welcome back to the Wefugees Community and thank you for reaching out to us again.
My colleague Éanna answered a very similar question here before. Please check his answer for more information. The father of your child may be issued a residence permit according to section 25 (5) of the German Residence Act. But it can get quite complicated. In any case, he needs to declare the fatherhood and it will be helpful (if not even necessary) that you both share the custody. As my colleague explained, the authorities probably want to see that he is actually taking care of the child as well/that they are in regular contact (incl. financial support, if possible).
Depending on the type of your own residence permit, it can be easier if you both get married, yes. However, the marriage procedure as such requires many documents you have to submit at the registry office (which can be challenging). At the end, the marriage is a big step as well and should be carefully thought out (without the residence permit being the main motive - but that's my personal opinion).
I hope this helps and please don't hesitate to get back to us with any further questions.
All the best,
Meike