From 23 million to 5 million years ago, Africa was covered with forests populated by great apes. Somewhere during that period, the climate began to dry, and the forests began to shrink. Many of the apes that lived in these forests became extinct. One, at least, somehow developed the ability to go between forest patches on two legs and became an upright walker. That is a very big question.
Scientists have several hypotheses.
One idea is that four-legged grassland apes began walking upright in order to hold tools. My research has shown that in fact, there wasn't any open grassland until about 1.8 million years ago. People were on two legs by 4.2 million years ago. In my own personal view, the ape that eventually became a biped was an arboreal animal, not a terrestrial quadruped. In other words, I don't think the animal just stood up, because it was not advantageous to be on the ground and not run on four legs.