Welcome to our community!
"I read somewhere that if a child has relatives who are legal here, it can help grant a legal status."
Being born in Germany does not lead to a German citizenship for the child. Only if the parents stayed here for at least 8 years and hold an unlimited residence permit.
Nevertheless, a child that is born in Germany runs through its own asylum procedure. And there is special protection for newborn children: If BAMF sends a negative reply it's not going to be deported separated from its parents.
Sources (German language):
But I don’t know if there is special rules or options that I don’t know about that could be of importance in your case. Unfortunately this is a complex matter that I am not an expert of. May I ask where you live right now? Maybe we can do some research about organisations that might help you out in your situation.
Or maybe @Marcel or @Steven have an idea.