This is a highly contested area of debate, even among experts in the field. Many different factors seem to be capable of influencing our moods in one direction or another. Our genetics, physical health, hormonal states, alcohol, drugs, medications, as well as nutrition, exercise, sleep, relationships, etc. all seem to influence how we feel.
With that said, the most direct and obvious cause of our feelings, at any given time, is what we are thinking in that moment. In short, we feel the way we think. People who feel guilty, for example, are telling themselves something like, "I shouldn't have done that" or "What I did was wrong". People who feel hopeless do so because they are telling themselves "I'll never succeed, it's impossible". People who feel angry are thinking "That person shouldn't have done that, what a jerk!", etc.
When a person is able to revise or talk-back to these thoughts, they can feel better immediately: they might say, instead, "It's o.k., I'm allowed to make mistakes sometimes", "I would prefer to have done a better job, this is a good learning experience", "I wish that person would have treated me better, but that's their problem, not mine", etc.
Some argue that since the mind is produced by the brain, there must be an underlying biological cause responsible for our moods. Others point out that, without altering the brain with chemicals or electric shocks, many mental activities, such as remembering a pleasant event, meditating or going to therapy, can result in sudden and drastic changes in mood. It seems that the brain is able to influence the mind and the mind is able to influence the brain. It may be that when our brains are sleepy, intoxicated and sick, this predisposes our minds to errors in thinking, that then lead to negative mood states.
What this means is that mental health depends on the healthy functioning of the brain (including proper nutrition, exercise, sleep, etc.) as well as healthy functioning of the mind (positive attitudes, self-respect, good communication skills). With determination and practice, you can achieve your greatest potential for health and happiness. I can help!