Imagine primitive humanity. Every day brought new levels of self awareness, more questions. Emotions needed names. Mood swings could be noted and charted. Feelings started to stimulate thoughts that affected the feelings.
Depression in animals seems to be a passing thing, for the most part. But humans, able to extrapolate so many possible outcomes from a single point in time, keep coming around to depressing concepts. It has shaped our course from the beginning of self awareness.
A self-aware creature knows its beginning and its end from almost any point in its existence. Not many know the full specific details, but endpoints are in view.
Very early, people must have learned that if they shared something that hurt them with someone who cared about them, the caring friend or family member often suffered mental anguish at least equal to that of the original sufferer. So someone who cares about his loved ones would try to avoid telling them about unpleasant things unless they needed to know.
Depressed subjects would soon learn that people who did not care about them didn't want to hear their blubbering.
"Get out of here, you're bringing me down," may have been one of the first phrases of organized language after "Look out!" and "Oh, gross, was that you?"
The depressed person might find a quiet place and begin to talk to no one. Before too long, he might discover that this helped a little.
While all this simple interpersonal stuff was going on, larger issues like Creation, Natural Disasters and Unequal Distribution of Wealth had given rise to gods. Since gods could be benevolent as well as wrathful, someone trying to keep his problems from becoming other people's problems could quickly decide his soliloquies were prayers to the God or gods. Feeling relieved after a session, the sufferer might return to the group and tell them in general, avoiding the depressing details of his own plight, how "prayer" had helped him. Like a new diet or popular psychology book, it would quickly become the rage. People would even gather in groups to do it, just as some of them had probably discovered that misery loves company and had gathered to weep over their woes already.
Telling a deity made it easier to say and to hear. The congregation could nod sympathetically and still walk out after the service feeling no more obligation to help than was convenient.