The woman may have gone through unimaginable pain to birth the child but the mother might be the reason the family was dysfunctional in the first place. Sometimes the father has a larger emotional impact on the child it should be completely up to them. Unless one of the parents is a wanted criminal then it should automatically go to the other one.
People get divorced for all sorts of reasons. Perhaps the mother was abusive, Or is not fit to look after the child? Just because she is a women, The child equally belongs to the father as much as they belong to the mother. Whomever has custody should be decided in the interest of the child, And what is best for them.
This is a topic which has troubled me, And I honestly do not know what the best way of settling this is. But I know that white people are not automatically more trustworthy than black people. Jews are not inherently better people than Muslims. Single mothers are not naturally healthier parents than single fathers.
This said, This is not a light topic. But it is only dependent on what environment will raise the child best. The parent must provide, Nurture, Teach, And protect the child regardless of his/her gender.