Maya is the whole creation of God it is the force of nature behind the world, it is representative of the world, however the problems arise when we get distracted by maya. Our aim is to be like God Niranjan purakh or unaffected by maya. It is said that if if you were to see maya she would present herself as a woman whose head was bald at the front and bald at the rear. The reason being that all the people who chase after maya have pulled all the hair out of the back of her head, however maya has so much respect for saints that she has gone bald from the front of the head because she keeps bowing at the feet of them and rubbed her hair away. The upshot of this being that maya always chases virtuous people.
Maya and ego or haumein are essential because God put them at the centre of every living being, they are our consciousness or control centre. Throughout your life this control centre or ego is the guardian of your security, welfare and progress. Without a deep commitment to the interests, preservation and progress of the self, to the exclusion of every other being you would never be able to survive the battle against the challenges from the environment. These forces have been the best means of securing survival and the progress of life from amoeba to man.
These have now become our disease, with the struggle against our elements and other species being won we are still unable to deal with the members of our own species. We commit sins and crimes to amass wealth ansd satisfy our ego, i.e. chase maya to fulfill our ego thus hurting mankind and causing ourselves pain.
Maya (or creation) itself is neutral neither good nor bad, it is our conduct with it that makes it good or bad. As you have rightly pointed out maya is essential to be given in charity and to do good deeds with, in that case it becomes a force for good. However, if you are a virtuous person and amass wealth and do nothing positive with it for you it becomes bad because you have not used it for the purpose it was given to you.