Firstly: It is tough, but if you are guided by the fact that this is not about you or your interests (at all), but rather about the interests of that child - then your approach will become clearer.
Secondly: Accept that unless the biological parents are abusing the child, that is where the child belongs and the reality is that the courts will have to be persuaded (beyond a rash, dirt or the mother's profession) before they interfere.
So what are you left with?
The biological parents don't sound like the kind of people who will hold it together for too long. Your first job is persuade them to let you remain as a constant in the child's life - so that you can be there to pick up the pieces when things fall apart. Two strategies here: Firstly, appeal to their good sense. You have loved and looked after their child when they needed it. The child has formed a bond with you. Ask them to let you be the aunty while being completely clear that they are the parents and make all the decisions. You want to visit from time to time - help out with school, when that comes and be part of a happy extended family. You will NEVER undermine them. On the other hand, if they child does become threatened through abuse, you will no about it and be there to intervene - keep records... of everything.
Secondly, if strategy one doesn't work, tell them that you have been advised by lawyers and psychologists that you should fight this in the courts and that you have a good chance of success given the circumstances under which the child came to be in your care and your ability to offer the child a loving home. However, you think it must be hard - no impossible - for a parent to be denied his/her child (you know what this feels like, even though you are just the surrogate parent). Therefore, you will ignore this legal advice and agree to hand back the child, provided they allow you to be an 'aunty'.
Either way, you will have to swallow your pride and your better judgment and try your best to make friends with people who you find distasteful (at present). You will have to develop some real empathy for their situation and be supportive, non-threatening and kind. You are doing this in the best interests of that child - in order that you may play a positive role in her life. It's not ideal and you may well have been able to offer a far better home and upbringing - but this is the hand you have been dealt, you cannot change the cards, so do the best you can in the circumstances, knowing full well that it may place a strain on you, your relationship and your family.