So, I recently came up with this question. I googled it, but couldn't understand the proper functions of E-coli bacteria. A little definition would be wonderful.
Nonpathogenic E.coli are a component of the gut microbiome of humans and many other organisms.
They are commensals, meaning that when they remain in the areas they have evolved to live in, and when they do not acquire virulence factors, they are benign. They live in our digestive tract and basically do nothing to harm us.
In fact, commensal microorganisms like E.coli can be considered part of the multicellular organisms innate immune system. They take up space on the exposed surfaces of internal organs such as the intestines and prevent the colonization of pathogenic strains of microorganisms.
Along with the endothelial cells and mucous, commensals form the barrier defenses that are the first line of protection against pathogenic organisms. Basically they are the good neighbors that don't cause problems and they don't leave space for bad neighbors to move in.
Problems can occur if they gain access to areas that are normally sterile. If the intestine is perforated and E.coli gain access to the thoracic cavity, they can become an opportunistic pathogen, as they will not be interacting with the host in a way that can control their proliferation. They can also come in contact with cells that are not expressing the necessary proteins to protect them from the E.coli.
You can also end up with the situation where a pathogenic bacteria or a bacteriophage carrying a virulence factor can transfer that virulence factor to the commensal E.Coli, turning them pathogenic.
But for the most part E.coli are there to take up space that could otherwise be colonized by harmful bacteria.
E. coli do not serve a human function but live inside our digestive system because our bodies can't prevent bacteria like them from living there. They live there because they can prosper and reproduce there. Most strains of E. coli do not cause problems for us, and by being part of the normal bacterial population in our gut they out-compete other, potentially more harmful bacteria and keep them suppressed. E. coli mainly live in the large intestine, not the stomach.