Your mouth naturally contains microorganisms, including fungi, viruses and bacteria. If your immune system, which fights infections, is weak, its ability to fight harmful bacteria is lowered. This can result in trench mouth, where harmful bacteria grow out of control, causing infection of your gums. This infection can damage or destroy the delicate gum tissue (gingiva) that surrounds and supports your teeth.
Large ulcers, often filled with bacteria, food debris and decaying tissue, may form on your gums, leading to severe pain, bad breath and a foul taste in your mouth. Exactly how these bacteria destroy gum tissue isn't known, but it's likely that enzymes and toxins produced by the bacteria play a role.
Source: http://www.mayoclinic.com