Pain is evolution's way of saying, "Don't do that. It will hurt you."
Sadness is evolution's way of causing us to value relationships, avoid their loss. "Don't lose this relationship, valuable commodity, etc."
Anxiety causes us to achieve goals, act within social norms, get work done etc. "Don't behave antisocially."
All of the above have been advantageous to have for our species and have (otherwise we wouldn't have them most likely) and can be viewed as positive mechanisms to be harnessed and managed rather than emotions to be squelched, over-medicated or eliminated completely