If everything was really haphazard and pointless, then asking “What is the purpose of life?” would itself be meaningless. But practical experience tells us there’s a reason for everything, even though sometimes it’s not obvious:
“Who left a mess in the kitchen?” (somebody did)
“I dunno.” (I don’t want to admit it was me)
To ask “why?” shows we’re willing to accept there is a purpose behind something, and a consciousness (or person) behind that purpose.
A reporter once asked Srila Prabhupada about the purpose of life. His quick reply: “The purpose of life is to enjoy.”
Our real, spiritual nature is to seek enjoyment. That’s what everybody does. The Vedas talk about the purpose of life in great detail: Krishna is the cause of all causes, the Supreme Enjoyer, and He expands Himself unlimitedly to make unlimited enjoyable relationships possible. That’s what He does.
If we want to enjoy, there are basically two ways to go about it:
1) the self-centered approach, and
2) the Absolute Truth-centered approach.
Way #2 to act in harmony with the ultimate purpose, with reference to an ultimate creator and controller—is called bhakti-yoga—real spiritual life. This results in actual (permanent) enjoyment.
Way #1 assumes “no God, no ultimate purpose,” or “it’s all about me,” and hopes “everything will turn out the way I want.” This results in hit-or-miss, short-lived “happiness” (and depression when it’s all over). This is materialistic life.
For more info on this topic, check out Bhagavad-gita, Chapter 15, verse 7