You need them for protein and fiber, Moore says. Such legumes appear to also help prevent certain diseases, according to a study. Beans are great to keep your blood sugar in check, which is crucial for the brain. They also have a lot of magnesium, which is needed for more than 300 functions in the body. High dietary intake of magnesium has been linked to a lower risk of dementia, according to the Alzheimer’s Drug Discovery Foundation.