In the olden days of English common law, the father automatically kept custody of his children in the case of a child custody disagreement. Fathers held the legal right to have physical custody of their children, including the earnings and labor of their children. The courts of the time believed fathers should retain this right because the fathers -- as the financial rulers of their households -- paid to educate, train and support their children.
Colonial American held the same view as old England, initially, that fathers should keep their children. Tragically, they did not have any enforceable parental rights. The courts and the law continued to decide cases like this into the 1800s, but the 1848 Women's Rights Convention in Seneca Falls marked the first visible step toward changing this tradition. At the convention, participants made the automatic custody rule for fathers one of their chief complaints.
Things were changing in society as the result of countless men joining the industrial revolution to become wage-earning factory workers rather than farmers, herders and tradesmen who spent a lot of their time imparting their knowledge onto their children. More and more, women -- who stayed at home to care for the house and home -- took on the role of the primary domestic caregiver. By the early 20th century, the idea of "motherhood" had acquired a special status and via a legal theory called the "tender years presumption" the custody of younger children was nearly always given to the mothers.
It wasn't until the social and societal revolution that followed in the 1960's -- when divorce in the United States became more commonplace -- that the idea of gender-neutral custody awards became more mainstream. These days, it doesn't matter if you're the mother or the father of your child, you will have an equal right to receive child custody under the law.
Source: The Conversatoin, "Child custody - parental rights vs the child’s best interest," J. Herbie DiFonzo, accessed May 23, 2018