How does it work?
To put it simply (I'm no doctor or nutritionist here), when we ingest and metabolize protein, our body derives one of the 20 amino acids in protein called Tryptophan, which is used to produce a neurotransmitter from the brain called Serotonin, which in turn is needed to produce a hormone called Melatonin.
Eat protein --> Trytophan --> Serotonin --> Melatonin
So, your body cannot produce the latter without the former.
How does it help?
In the central nervous system, serotonin helps regulate anger, aggression, body temperature, mood, sleep, sexuality, appetite, and metabolism. It is often used as mood elevators or antidepressants. Basically, it helps to improve your mood and make you feel better, aside from endorphins, another 'happy' and mood elevating hormone produced when you exercise.
Melatonin is important to help regulate the circadian rhythms of the body (control the cycle of bodily functions) and helps you sleep.
So if you're feeling down or depressed most of the time and can't sleep, go grab that protein shake and eat more protein!
For a simple and visual explanation: