When people cry when sad the tears actually help as a natural painkiller and can help the person overcome the sadness.
That is because our tears release neurotransmitters known as leucine enkephalin.
When a person is happy that same neurotransmitter makes them feel that much happier and is a cause of why a person cries when happy.
I cry sometimes myself when I'm happy also because I'm overcome with emotions and when a person is overcome with emotions they can cry.