Researchers have called this feeling a "helper's high" where attitude towards yourself as a person shifts towards a more positive tone after being helpful to someone else (Luks, 1988).
What researchers have observed while studying this has been a trend of spiked circulating endorphins immediately after helping someone. Being compassionate also activates reward pathways in the brain that release positive emotions (Pace et. al, 2009). It also releases oxytocin to make you less stressed. So, by being a compassionate person and helping out someone else, you relieve yourself of stress and feel good about yourself (Shamay-Tsoory & Lamm, 2018).
A research team from Emory University tested the effects of compassion on the body following a lab-simulated stressful event. What they found is compassion reduced psychological distress as well as reduced systemic inflammation. Showing compassion allows for physical changes in the body to demonstrate a positive environment both externally and internally.
References
Luks, A. (1988). Doing Good: Helper’s High. In Psychology today (Vol. 22, Number 10, p. 39). Sussex Publishers, LLC.
Pace, T. W. W., Negi, L. T., Adame, D. D., Cole, S. P., Sivilli, T. I., Brown, T. D., Issa, M. J., & Raison, C. L. (2009). Effect of compassion meditation on neuroendocrine, innate immune and behavioral responses to psychosocial stress. Psychoneuroendocrinology, 34(1), 87–98. https://doi.org/10.1016/j.psyneuen.2008.08.011
Shamay-Tsoory, S., & Lamm, C. (2018). The neuroscience of empathy – from past to present and future. Neuropsychologia, 116(Pt A), 1–4. https://doi.org/10.1016/j.neuropsychologia.2018.04.034