Our ancestors of 6 million years ago were very much like the current chimpanzee. They were real tree dwellers and also spent their nights in trees. They built a nest for every night. They could not be seized by a jaguar, a predator that is primarily in the forests in search of prey.
However some millions of years ago there was an underground movement in Africa in the semifluid mass underneath the hard shell on which the living nature exists. The East point where Somalia is located broke loose from the Mainland and drifted away in the direction of the Indian Ocean. Mind you only by a few millimetres per year. At the same time high mountain ridges along the edges were formed. Between these ridges a savanna arose, but with few trees.
So in the immense chimpanzee population in sub-Saharan Africa there was a very confined population that no longer could live in trees. They started to walk upright and they became bipeds. They slept more and more close to each other under shelters to hide from the predators.