Praise be to Allaah.
The best way for a child to be brought up is with both of his parents, because if he is cared for by both this will strengthen him physically, enhance his intellectual development, keep his soul pure and prepare him for life.
If it so happens that the parents separate, then the mother has a greater right to custody than the father, unless there is reason not to give priority to the mother or there is a reason to give the child the choice in the matter.
The reason why the mother is given priority is that she is the primary caregiver and is the one who breastfeeds the child; she is also better able to care for the child and take care of him. She has more patience than a man in this regard, and has more time than he does, so the mother is given priority in the best interests of the child.
It was reported from Abd-Allaah ibn Umar that a woman said, O Messenger of Allaah, my womb was a container for this son of mine and my lap was a haven for him, and he drank from my breast, but his father is claiming that he should take him from me. The Prophet (peace and blessings of Allaah be upon him) said: You have more right to him (to custody of him) so long as you do not remarry.(Narrated by Ahmad, 2/182; Abu Dawood, 2276; al-Haakim, 2/225. Classed as Saheeh by al-Haakim).
Yahyaa ibn Saeed said: I heard al-Qaasim ibn Muhammad said: Umar ibn al-Khattaab had a wife from among the Ansaar who bore him Aasim ibn Umar, then Umar divorced her. Umar came to Quba and found his son Aasim playing in the courtyard of the mosque. He took him by the arm and seated him in front of him on his riding-animal, but the childs grandmother caught up with him and fought with him over the child until they went to Abu Bakr al-Siddeeq. Umar said, (He is) my son! and the woman said, (He is) my son! Abu Bakr said: Leave them alone, and Umar did not answer back.(Narrated by Maalik in al-Muwatta, 2/767; al-Bayhaqi, 8/5). Ibn Abd al-Barr said: this hadeeth is well known with a variety of isnaads, complete and incomplete, and is accepted by the scholars.
According to some reports, [Abu Bakr] said: the mother is more compassionate, more kind, more merciful, more loving and more generous, and she has more right to her child unless she remarries.
Abu Bakrs description of the mother as being more compassionate and more kind is the reason why the mother has more right to the custody of her young child. And Allaah knows best.