Job no longer exists on return from maternity leave: ask the expert
You have raised a number of issues which I will deal with in broad terms, but I can't answer all of your specific questions without speaking with you.
It may still exist. Under a piece of legislation called TUPE the transferee (the outsource employer) may have been obliged to employ you. I would need more information on this in order to give you advice that you can rely on, but potentially if they say your job does not exist you may have claims for unfair dismissal and discrimination against both your employer and the out-source employer.
Also, the decision to out source could be discriminatory if you can show that, but for your pregnancy and/or maternity leave, your job would still exist i.e. their decision to out source was influenced by your pregnancy and/or maternity leave.
Denying a flexible working request because it would set a precedent is not permissible under the flexible working regulations. It may also be indirect sex discrimination.
I suggest you get advice on next steps. Keep a log of all events and conversations to date and in the future. And check if you have legal expense insurance on your home contents insurance policy.
Vanessa Wheeler is an employment and commercial law solicitor at Setfords Solicitors. Vanessa has particular expertise in maternity and discrimination law; she has commented on employment law for the Guardian and for BBC Radio 4's Woman's Hour.