Narcotic drugs are used for medical purposes to function by connecting with opioid receptors in cells to relieve pain.