Why do you think Allah created things like depression and anxiety? I want a refund on my current life.
For the same reason He created things like poverty and loss. God wants this universe to be a testing hall for humanity. The best humans prove their love and loyalty toward God by maintaining a close relationship with Him despite all their sufferings. While the worst ones start to hate God until their grudges against Him lead them to the point where they deny His existence.
Why did God allow Prophet Muhammad to suffer horrible injustices, failures and persecutions in Mecca for 13 years when He could have given him instant success? Because that’s how God has designed the universe. We need to suffer through time patiently to prove our characters to Him. You cannot prove your love and loyalty to a king by being obedient and dutiful for one day or one month. You prove it when you go through immense suffering for him, get all kinds of temptations to be disloyal toward him or to hate him, and yet maintain your love and loyalty. That’s the kind of friend that any king would love.
Please also see my essay: Islam and Depression: A Survival Guide