Welcome to the Wefugees Community and thank you for reaching out to us.
Without knowing your personal situation, we can of course only make general explanations here.
If it comes to the residence permit accoriding to Section 25 (5), the immigration office (Ausländerbehörde) indeed has a scope for decision-making, which often makes the procedure intransparent and difficult to understand. As @Obumkelly79 mentioned already, understanding the rejection letter (or asking for it, in case you haven't recieved one) will give first hints in terms of the immigration office's logic and reasoning. At the end, hiring a lawyer to support you against the immigraiton office will most probably be the most promising option now. Please keep in mind, that talking to an experienced counselor could be a lower cost alternative or you apply for a "Beratungshilfeschein", for instance. For brief information on this, you may also read this thread.
I hope this helps and don't hesitate to get back to us with any further questions.
All the best,