The answer is “we don’t know”
Just like the secular question “Why is there something rather than nothing?”
Or “Why is there anything at all?”
And The question for religious people would be “Why God created anything?”
But in reality we are asking the same question with “different vocabulary”
Your question is in the same category.
Religious people know that God created everything_ but “why he created it?”_ is beyond the capacity of our brain and senses and understanding
I think we should not pretend to know something that “we don’t”
But hypothetical If god were to ask me again “Would you like to be created as a human and be tested On the Earth with suffering,in return to forever Paradise?”
I would say yes without hesitation_ Because without this there is “no me”_ so pain and suffering along with happiness and joy_ ” is the existence of me”
And I would choose my it again and again_ Because i want to exist and go to forever paradise