Complex environments result in the evolution of complex organisms. Of course, one should also point out that the presence of complex organisms results in a more complex environment. And heterogeneity results in a more complex environment as well.
Thus, once life emerged and began evolving, the living environment became more heterogeneous, and thus more complex. And this drove the evolution of greater complexity. Which drove the emergence of more complex environments. Which drove the evolution of greater complexity. Etc.
Which eventually get us to us. We also create more complex environments, within which we evolve more complexity. This is the argument of Gravesean psychology. Complexity drives complexity.