Synthetic and natural opioids have the same mode of operation on your brain as endorphins. They bind to these things called "opioid receptors"[1] in your brain. There is a biological purpose for the existence of these receptors. Quoted from Wikipedia: "The endogenous opioid system is thought to be important in mediating complex social behaviors involved in the formation of stable, emotionally committed relationships."
Opiates actually seem to have a significant benefit to people suffering from severe and refractory major depression, where all other legal anti-depression medication has not helped them.[2] Now compare this with alcohol (ethanol) -- a substance that recklessly goes around destroying cells in your brain and your liver, which people take just to get rid of some social anxiety. Huh.