The gut-brain axis is a communication channel that mediates a complex interplay of intestinal flora with the neural, endocrine, and immune systems, linking gut and brain functions. Gut metabolites, a group of small molecules produced or consumed by biochemical processes in the gut, are involved in central nervous system regulation via the highly interconnected gut-brain axis affecting microglia indirectly by influencing the structure of the gut-brain axis or directly affecting microglia function and activity. Accordingly, pathological changes in the central nervous system are connected with changes in intestinal metabolite levels as well as altered microglia function and activity, which may contribute to the pathological process of each neuroinflammatory condition. Here, we discuss the mechanisms by which gut metabolites, for instance, the bile acids, short-chain fatty acids, and tryptophan metabolites, regulate the structure of each component of the gut-brain axis, and explore the important roles of gut metabolites in the central nervous system from the perspective of microglia. At the same time, we highlight the roles of gut metabolites affecting microglia in the pathogenesis of neurodegenerative diseases and neurodevelopmental disorders. Understanding the relationship between microglia, gut microbiota, neuroinflammation, and neurodevelopmental disorders will help us identify new strategies for treating neuropsychiatric disorders.