I know it's cough syrup. Or, more precisely, it's hydrocodone that is used for, among other things, cough suppression, as well as pain management. That is why he told me to use it for sleep - it suppresses any pain and actually works well. I'm not sure why it comes as a syrup - maybe people with a cough want cough "syrup", not pills?
As for Doctors prescribing it for anything else, it's called off label use, and unfortunately Doctors do that all the time.