A lot of people think women couldn't get good jobs in the past simply because of prejudice, but that's not how it started.
Thousands of years ago when it wasn't safe to hunt while pregnant, nursing, and/or caring for little kids. Women could take their toddlers and infants along while gathering fruits and edible plants, but even then if they took their eyes off a little one for a few minutes it might wander off and be eaten by a wild animal.
Even when humans started doing farming and herding it would have been difficult to care for babies and little kids while out in the sun all day, and to keep them from damaging the crops or bothering the animals. Physical jobs like felling trees, mining, and making things from metal were not safe to do around little kids. And, of course, it would have been impossible for women to take children along while serving as soldiers or sailors.
Since people back then didn't live nearly as long as they do now, grandmothers weren't likely to be available to provide childcare. It was simply more practical for women to stay close to home and do things like cook and make clothing while the men went out and got the provisions.
And humans tend to be creatures of habit. By the time women had stayed at home for centuries everyone assumed that was the way things ought to be.