Allah knows that certain human beings will go to hell. Imagine your mother finds out that you are going to hell and she has the capacity to undo all of your actions she would do it by all means . My question is why created all of this test? why not let all of us live in heaven?it would be more loving to live all of his creation in heaven rather than creating all of this Test?
"Imagine your mother finds out that you are going to hell and she has the capacity to undo all of your actions she would do it by all means."
Yes, because your mother is biased for you. A mother's love can be misguided. A mother can love a murderer. But, Allah is at the same time Just.
Allah loves all people equally, so he punishes those who wrong other people. Your mother too punishes you if you wrong your brother or sister.
And your mother would certainly not help you if you ignored her for all your life and respected another woman as a mother even though your mother took complete care of you. And you disrespected your mother, disobeying every command and request she made of you. And when your brother (from the same mother but who actually obeys her) came an asked you to obey her you ridiculed him and did not listen to him either. Such is the case with Shirk but you do it with Allah who loves you and provides for you much more than your mother. In such a situation your mother would not stop you from going to Hell, and neither will Allah because you deserve it.
My point is that Allah does start out loving everyone a lot just as your mother starts to love you when you are a baby. But as you become an adult and become a terrible person, a morally good mother would not love you as much. Her love will wear away. But if you become a good person. Great, her love is only added to.
Likewise is Allah. He provides for you to live and loves you in the beginning, and if you die when you are young he will give you Jannah out of his Mercy and love. But, your sins and disbelief remove that love (though asking forgiveness will always get His love back).
Allah does not love disbelievers and transgressors:
Allah does not love the disbelievers (3:32)
Allah does not like the unjust (3:140)
He does not like the arrogant (16:23)
And he loves those who are pious and good:
Indeed Allah loves the virtuous. (2:195)
Allah indeed loves the Godwary. (3:76)
Allah loves the patient. (3:146)