Rather than giving a purpose – the world is for this reason, that reason – because for the advaita vedantin since there is no real creation, they are not going to give you the reason for creation.
From the Buddhist perspective also, the world is as such is messed with dukkha, and nobody created the world as such, it is beginning less, going on stream pravah or flow that you cannot ask why. It’s just going the way it is.
From the Trika perspective, because there is the central Divinity then the question is valid. Why would the Lord create a miserable world? And that is where the Shaivas differ. Why do you conclude that the world is miserable? You are used to seeing glass half empty. Why can’t you start seeing glass half full? The world has both things. We learn about enjoyment, fun, being in the world and we pick the dirt while we play on the ground and then we became miserable. The more the dirt we pick up, the more miserable we become. If we were to clean, wash off all the dirt we picked up in the process of time, we would go back to the same pristine natal state of joy.
And the world as such is joyous, we are just tied with our limited body and limited mind and mental projections, all our anticipations and then we project it to be full of suffering. It does not need to be like that. You can choose the world to be full of suffering and suffer. But you can also choose the world to be a magical place. So, they developed some kind of magical realism that the whole world is almost like endless magical projection in not having any particular beginning or ending, unfolding a whirlpool of multiple streams.
Dr. Sthaneshwar Timalsina, Introduction to Kashmiri Shaivism