Immunity is not a function most people particularly associate with the liver. But because of its connection to the gut, the liver is exposed to bacterial metabolites as few other organs are. And when either the liver or the gut is not functioning well, it can adversely affect immunity as well.