An inadequate diet can lead to imbalanced gut functions which create difficulty in absorbing nutrients and involves weight gain or loss. It also affects mental health through impaired decision-making and can slow down reaction time. A poor diet can aggravate, or lead to stress and depression.

Do you know which hormone regulates your mood?
The answer is most likely serotonin, it is a brain chemical or hormone which is responsible for regulating mood.

Over 90% of the body’s serotonin is produced in the gut, where it has a protective effect. The health of your stomach (gut health) and the balance of bacteria impact our stress resilience and immunity.
The autonomic nervous system (ANS) controls this stress response and controls other involuntary functions like digestion, heart rate, and respiration. That is why we tend to feel emotions like fear, anger, and disgust in our stomachs. Serotonin helps to regulate autonomic functions in the central nervous system.

So, when our stomachs are happy, we tend to be happier too.
Here is a research note for your understanding,
In 2019, the Baylor College of Medicine conducted a study on gut permeability and depression. They found that a leaky gut (A digestive condition in which bacteria and toxins can “leak” through the intestinal wall.) was associated with increases in both depression and stress response.

The relationship between the stomach and the brain goes both ways — it is bidirectional.