Allow me to present to you my opinion. It is true that allah did not gain anything from this creation. But here is the thing, what else do we know about the glourious allah swt? We know he is all knowledgeable and all merciful. But what does that mean? That means he knew before he made all of us that the sensation of living is something we love. Even towards suicidal people, suicidial people enjoy the sensation of life but want to end it because of its challenges. However, the mercy comes in the form of providing another life the chance at eternal life. I mean think about it, isnt allah swt the most amazing purely because he is giving you an open opportunity at eternal joy and happiness? He gains nothing from this, but because of his conpation for the non conceived he created us. Because once one thinks about it, what is better non existence or eternal existence with pure joy and satisfactoin. So the simply answer for why allah created anything if he gained nothing is that he created things to show his compassion to you by providing you with a chance at eternal life with total content. This is the concept of genourosity and it is why allah is also the most genorous. Hopefully this answers your question. Excuse my spelling I'm a little tired