The "purpose" of morality, insofar as any naturally occuring thing can be said to have a purpose, can be assumed to be a group survival mechanism - a way for genes to cooperate with copies of themselves in other individuals.
However, somewhat paradoxically, effective morality demands that you ignore its instrumental value. To be a useful engine of cooperation, it must be trustable - people need to be able to rely on you to do the "moral" thing even if it's inconvenient. Much like the irrational violence accompanying the emotion of 'anger' is seemingly maladaptive in the individual level, yet the threat of violent rage is game theoretically powerful (and is undermined if perceived to calculated rather than "genuine emotion"), so morality also demands that you prove yourself to be a "true believer" by doing irrational things that incur a personal cost.
tl;dr the "purpose of morality" is scientifically interesting but you are not permitted to entertain the question as it pertains to yourself and still call yourself moral.
However, somewhat paradoxically, effective morality demands that you ignore its instrumental value. To be a useful engine of cooperation, it must be trustable - people need to be able to rely on you to do the "moral" thing even if it's inconvenient. Much like the irrational violence accompanying the emotion of 'anger' is seemingly maladaptive in the individual level, yet the threat of violent rage is game theoretically powerful (and is undermined if perceived to calculated rather than "genuine emotion"), so morality also demands that you prove yourself to be a "true believer" by doing irrational things that incur a personal cost.
tl;dr the "purpose of morality" is scientifically interesting but you are not permitted to entertain the question as it pertains to yourself and still call yourself moral.