Creation, as we understand it, is a cyclic phenomenon. It did not have a beginning in the sense that it did not come into being at any particular point in time. A beginning is a coming into existence of something that did not exist earlier.
There was never a time that the creation was not; it has always been. Only, it is a cyclic phenomenon of creation, sustenance, and dissolution, from being manifest to becoming unmanifest and then manifesting again.
This is like a seed becoming the tree that produces the seed that again becomes a tree, or like water rising to become the cloud that comes down as the rainwater that again rises to become a cloud, and so on. Similarly, this creation is also a perpetual cyclic phenomenon.
The purpose of creation as in 'why' can be asked only provided there is a beginning. Something that has a beginning is an effect and so there can be a cause. Thus, if there were a cause you could ask 'why'.
There is no cause for the creation as such because it has no beginning and so one cannot question why it exists; we can only inquire into the purpose of a given cycle of creation. We can imagine countless cycles of creation. A cycle of creation from manifestation to sustenance to dissolution takes place over billions and trillions of years.
That is the span of a cycle of creation. Why is the creation there at all? There is no answer to that. Yet we can ask what caused the very first cycle of creation as in what caused the unmanifest to manifest.
The cause for the primary cycle of creation can be understood through the example of the cycle of sleep and waking. When we go to sleep, we are in a state of being unmanifest or in a causal state. When we wake up there is a state of manifestation. Sleep surfaces into wakefulness, which goes back into sleep that again emerges into wakefulness, and so on.
This is the cycle of one's being manifest to one's becoming unmanifest and then, from being unmanifest, to becoming manifest again. You can ask what it is that makes you wake up from the state of sleep.
"Is there something because of which I wake up?" The answer is yes. When you are in the state of deep sleep, whatever unfulfilled desires you have lie dormant within you; it is those desires, which, when ready to express themselves, wake you up.
This is the reason you wake up and it is this that makes the creation what it is. Why is the creation how it is? The answer is that it is the result of the total desires of all the living beings; they were all 'sleeping' in a state of dissolution and then they all needed to wake up to fulfill their desires. Therefore, the creation is as it is in response to the desires of all the living beings.
There is an appropriate field for the expression of the desire of every living being in this creation. Whatever be the basic needs of all the creatures, including the human being, there is a provision for the fulfillment of all those needs. The purpose of creation, therefore, is to provide all the living beings with an appropriate field so that they can fulfill their desires. It therefore exists in response to the need of all the living beings.
That is how we can understand the purpose of creation. What is our role in this creation? Well, as human beings, we are born with an agenda. Our birth is no accident. It does have a purpose. Other than the human being, as far as the other creatures are concerned, the purpose of birth seems to be to simply fulfill the basic instincts of eating, drinking, self-preservation, and self-propagation.
That seems to be the purpose of their lives. But the human being is born with a desire to attain freedom. I cannot accept the bondage; I want freedom. And, therefore, the human being is born with an agenda.
Our role would then be to live a life, which is compatible with fulfilling our desires. If freedom or moksa is the desire, then our lives should be compatible with the fulfillment of that desire. When can we gain moksa?
That will happen when we gain self-knowledge.