We compulsively wash our hands, spray our countertops and grimace when someone sneezes near us—in fact, we do everything we can to avoid unnecessary encounters with the germ world. But the truth is we are practically walking petri dishes, rife with bacterial colonies from our skin to the deepest recesses of our guts.

All the bacteria living inside you would fill a half-gallon jug; there are 10 times more bacterial cells in your body than human cells, according to Carolyn Bohach, a microbiologist at the University of Idaho (U.I.), along with other estimates from scientific studies. (Despite their vast numbers, bacteria don't take up that much space because bacteria are far smaller than human cells.) Although that sounds pretty gross, it's actually a very good thing.

The infestation begins at birth: Babies ingest mouthfuls of bacteria during birthing and pick up plenty more from their mother's skin and milk—during breast-feeding, the mammary glands become colonized with bacteria. "Our interaction with our mother is the biggest burst of microbes that we get," says Gary Huffnagle, a microbiologist and internist at the University of Michigan at Ann Arbor. And that's just for starters: Throughout our lives, we consume bacteria in our food and water "and who knows where else," Huffnagle says.

Starting in the mouth, nose or other orifices, these microbes travel through the esophagus, stomach and / or intestines—locations where most of them set up camp. Although there are estimated to be more than 500 species living at any one time in an adult intestine, the majority belong to two phyla, the Firmicutes (which include Streptococcus,Clostridium and Staphylococcus), and the Bacteroidetes (which include Flavobacterium).

For a long time, scientists assumed that these bacteria, despite their numbers, neither did us much harm nor much good. But in the past decade or so, researchers have changed their tune.

For one thing, bacteria produce chemicals that help us harness energy and nutrients from our food, Huffnagle explains. Germ-free rodents have to consume nearly a third more calories than normal rodents to maintain their body weight, and when the same animals were later given a dose of bacteria, their body fat levels spiked, even if they didn't eat any more than they had before.

Intestinal bacteria also appear to keep our immune systems healthy. Several studies suggest that microbes regulate the population and density of intestinal immune cells by aiding in the development of gut-associated lymphoid tissues that mediate a variety of immune functions.

The bacteria also appear to influence the function of immune cells like dendritic cells, T cells and B cells, although scientists don't know the precise mechanisms yet. And one chemical released by the bacterium Bacteroides fragilis is capable of directing how the developing immune system matures.

Further, probiotics—dietary supplements containing potentially beneficial microbes—have been shown to boost immunity. Not only do gut bacteria "help protect against other disease-causing bacteria that might come from your food and water," Huffnagle says, "they truly represent another arm of the immune system."

Of course, they can't protect against every onslaught, which is why we still have to depend on antibiotics to rid us of some disease-causing infections. But antibiotics don't just kill off the "bad" microbes, they wipe out the "good" ones, too. That's why antibiotic use can cause diarrhea and upset stomach: The drugs interfere with the balance of our bacterial flora, making us sick, Huffnagle explains.

But the bacterial body has made another contribution to our humanity—genes. Soon after the Human Genome Project published its preliminary results in 2001, a group of scientists announced that a handful of human genes—the consensus today is around 40—appear to be bacterial in origin.

The question that remains, however, is how exactly they got there. Some scientists argue that the genes must have been transferred to humans from bacteria fairly recently in evolutionary history, because the genes aren't found in our closest animal ancestors. Others argue that they may be ancient relics from evolutionary events that took place early in our species's history and, for reasons unknown, the genes were lost in these ancestors. It's impossible to know for sure at this point.

"There remain to my knowledge no clear cases of human genes recently acquired from bacteria," says Cédric Feschotte, a biologist at the University of Texas at Arlington. "It doesn't mean there are none, but they are not well documented."

One thing is for sure: our lives and even our identities are more closely linked to the microbial world than we may think. Bacteria do a lot to keep us healthy, and scientists are just beginning to uncover their valuable secrets. As U.I.'s Bohach says: "We do not completely understand the full impact of our bacterial flora on our health and physiology."

Scientific American is part of Springer Nature, which owns or has commercial relations with thousands of scientific publications (many of them can be found at www.springernature.com/us). Scientific American maintains a strict policy of editorial independence in reporting developments in science to our readers.