Mantra is a subtle sound that vibrates with the cosmos. Every person has his or her own mantra, based on their subtle body. Resonance effect in physics says when you vibrate something at the right frequency it produces a sound, similarly using the mantra in the right way has a positive effect on the mind. When someone in a moment of anger says something that hurts you, it has a negative effect on the mind.  Mantra calms down the mind, it cancels any negative vibrations. I like to think of this as ripples on the pond, the surface of the pond is the mind and the ripples represent disturbance. On a superficial level mantras damp out these ripples and calm the mind, but they also effect at a much deeper level. Though there are very many good books that explain the theory of the mantras, you should get your own mantra through an advanced teacher. It is like prescription medication, if you dont have the right prescription it will create problems.