Hmm.. I just did a little research into melatonin, and i think i figured out why it's so effective, especially with anxiety/insomnia sufferers.
Alot of anxiety sufferers have low levels of serotonin (hormone thought to be associated with anxiety) so taking meds which bring that level back to normal will pretty much cure it, as well as having big effects on sleep patterns.. and general energy levels. Here's what i think happens..
Serotonin is produced during the daylight hours, which keeps us happy and alert and anxiety free when we're (normally) awake.
Melatonin is produced by the same gland as serotonin, but during the night. So when darkness falls, the brain sends signals for the gland to stop and change any serotonin into melatonin. Then the body rests as we sleep, and wake to daylight hours and the gland changes melatonin back into serotonin so we can go about our day again.. A person with normal levels of serotonin and melatonin will have no problems sleeping, and probably no problems with anxiety either.
But if for some reason we have a low level of, say, serotonin then when it gets dark and the glands go to work to make melatonin.. there wont be very much, if any, serotonin to turn into melatonin, and so it becomes hard to fall asleep. Then when we wake there will be a low level of melatonin so the gland cannot make serotonin either.. it gets into a cycle, and we suffer because of it.
My theory is when people start getting anxiety problems it's because of an inbalance in serotonin/melatonin levels, so anxiety leads to sleep problems, and sleep problems lead to more anxiety. This is probably why meds which normalise serotonin levels have such a big effect. If you normalise serotonin levels then it will have a knock on effect on melatonin levels, and bring them both back into balance. And vice versa with melatonin supplements.
Why the balance gets knocked out in the first place I don't know. Maybe a gland problem, or maybe the relationship between the two hormones is very sensitive and easily put out of synch.
In summary:
Low level serotonin + low level melatonin = anxiety + sleep problems
It's just a theory, I could be totally wrong, but it would make sense of alot of things. If you've made it this far through my ramble then let me know what you think