Masochism is the joy of pain. Like sadism, masochism is often linked to domination and submission. However, while commonly true, SM does not require a D/s dynamic and in some cases the roles are reversed - sadistic submissives and masochistic dominants.
Originally though of a severe mental illness caused by lack of self-worth, today several emotional and physical reasons have been found. Like other stress or edge experiences, S&M scenarios can cause seratonin and melatonin levels in the brain to change. Testosterone and endorphone are also at least temporarily effected by S&M experiences. While the cause for endorphone release is simply explained by the pain inflicted, changes in testosterone levels are not that easily explained. Scientists currently do not link testosterone changes to the S&M experience but rather to the feelings of dominance and submission created by giving/receiving pain.