People with vitamin B12 deficiency usually report significant mood changes. Reduced levels of the vitamin have been linked to mood disorders like depression  and brain disorders like dementia. A suggested potential explanation for this condition is the “homocysteine hypothesis of depression.”
According to the homocysteine hypothesis of depression, it is suggested that the increased levels of homocysteine caused by reduced levels of B12 could lead to damage to the brain tissue and intersect signals to and from the brain, causing mood changes.
Some research suggests that in a set of deficient individuals in the vitamin, supplementing with B12 can help reverse the symptoms. Note that mood changes and medical conditions like depression and dementia can have different causes, so supplementing these conditions is not completely comprehensive.