For me it was an unintended side effect from starting to meditate. It dawned on me one night that I could just quiet my mind long enough to fall asleep. I wish someone had told me that was a use for the skill, I would have learned it way sooner.
Years ago I noticed that when I used meditation techniques to quiet my mind, it made me sleepy. It's possible that it was just revealing a bit of underlying sleepiness that was usually masked by busy activity. So, I started using it when I was having trouble sleeping, and it worked like a charm. I've been doing it for years and taught my kids how to do it. My elementary school kid, who tended to be on the anxious side, really liked it.
Only problem is that now I get even sleepier when I try to meditate. ;-) Oh, well, I'd rather sleep well than meditate if I can't have both.