We don't know.
All of the great apes are incredibly intelligent in comparison to most other animals. The basic roots of our intelligence are probably a common feature to the whole family, but there's no consensus on why it's so advanced in humans. Any paleoanthropologist can rattle off about half a dozen possible explanations, but we honestly don't have enough evidence to really distinguish if, when, and how these were factors at different points in human evolution. Here's a quick attempt at some broad categories, which each have multiple hypotheses within them:
* Because intelligence had advantages for individual selection (e.g. mimetic recall hypothesis)
* Because intelligence had advantages for group selection
* Because intelligence had advantages for sexual selection (spandrel hypotheses often start here)
* Because adapting to rapidly varying ecological conditions required so many adaptations that we crossed some kind of barrier and "fell into" intelligence
* Because intelligence helped with foraging/hunting (exclusive of sociality)