Two things can grow together. According to a published study from the University of Texas at Austin and Stony Brook University, the human skull became what it is today just as human legs became fully formed for walking.
Back in the day humans climbed trees and crawled around from place to place. Basically they were all little children in the way they navigated around. This was believed to be between 6 and 3 million years ago, well before humans began seeing major physical changes like longer legs. Researchers note that over time, as humans began gravitating towards walking, they needed a "new head" to fit proportionally atop their spine.
For awhile, the evolution of bipedalism as consisting of a forward shifting foramen magnum has been thought to be a feature of humans and their fossil relatives, but the group of UT-Austin and Stony Brook researchers have found that it could apply to bipedal mammals in general. They compared the position and location of the foramen magnum across 77 mammal species ranging from primates to rodents and found them to have a more forward-positioned foramen magnum than most other quadrupedal creatures. In 2007, researchers studied chimpanzees on treadmills and concluded that chimps required 75 percent more energy to walk than humans. This could have a lot to do with their foramen magnum structural differences. It's unclear if they'll be able to find any species of bipedal apes.
Today's findings aren't the first to deeply examine the connection between skull size and legs. In the 1920's, anatomist Raymond Dart unearthed an ancient skull in South Africa known as the Taung Child. Initially, many researchers were convinced the child was merely an ape. They were wrong, it's foramen magnum was positioned too far forward to belong to an ape. The creature had to have walked upright.
The timeline regarding the evolution of walking is pretty well understood at this point. In 1871, Charles Darwin chronicled it in his book, The Descent of Man claiming that hominids discovered walking on two legs in order to free up their hands.
There's also an element of monogamy tied in. Anthropologist C. Owen Lovejoy suggests that changes in climate made African forests more seasonal and tougher for humans to find food. This caused them to delegate tasks. The males would wander and gather food while the females would stay back and raise the offspring. Naturally, males needed to carry lots of goods and have the legs to help get them there. Gotta love evolution.