There's at least two possible ways for it to help:
1) Feeding different gut microbes. Often, pathogenic fungi and bacteria feed on simple carbs, which are abundant in normal diets, and drive inflammation that causes mental and physical illness
2) Ketone bodies are an alternative fuel for the brain that does not rely on glucose uptake mechanisms, which are often impaired by (pre)diabetes, inflammation, shit sleep, etc. all of which are very common.