The effect of the gut microbiota on the brain in the human holobiont is an incredibly complex story. It is described in a review appeared in 2019 on the "Physiological Reviews" journal. Not so much a review as a whole treatise, it is huge, with 1694 references in the bibliography!!! You can find a more readable summari on the blog "gut microbiota for health"
Before going on, a note of caution: as it is the rule nowadays, most of what appears in the medical literature is biased or simply false as the result of the widespread corruption of the medical research system. This review has been partly sponsored by the pharmaceutical industry, nevertheless it seems reasonably free of hype for specific treatments or wonder drugs. Its approach is correctly evolutionary, for instance when they say:
"Given that there has never been a time when mammals existed without microbes (apart from under highly restrictive laboratory conditions), there has also never been a time when the brain has been without signals from the gut, and it is important to consider the relationship between the host and its microbiota from an evolutionary perspective"
And they have it perfectly right when they use the magic word "holobiont"!!!
"The hologenome theory may even account for complex biological phenomena such as certain behaviors. For instance, behavior that facilitates social interaction among holobionts might be considered evolutionarily adaptive/advantageous as it gives rise to greater transmission of microbiota, thereby enhancing genetic variation (1285, 1286, 1689). In light of these inextricable links between the microbiota and the brain throughout evolutionary history, it is imperative for the study of our own biology (and that of the entire animal kingdom) to understand how microbial symbionts influence brain physiology and behavior."
The main point of the paper is that the human brain is strongly influenced by the gut, that our behavior, to the point that modifying the gut composition can be seen as a form of "psychobiotic therapy" that improves plenty of pathological situations and improves also the quality of life, for instance helping against depression.
Seeing how the world is behaving nowadays, it would seem that the human microbiome is in bad conditions, indeed. Especially the gut of our leaders seems to have been invaded by micro-monsters instead of the beneficial gut flora that's normal for humans. And, surely, the various habits of hyper-cleaning, distancing, and self-suffocation that became fashionable during the past two years didn't help in improving the situation. Maybe, at this point, only our bacterial and viral friends can help us (with a little support also from our friendly archaea and fungi). Go, friends, go! We need you badly!