Our biology includes a moral sense. That biology is defective in rational psychopaths (perhaps 4% of men) who have diminished ability to experience the emotions of empathy, gratitude, loyalty, and guilt and concern for fairness and the well-being of others. The motivating mechanism of a rational psychopath’s moral compass is weak to non-existent.
For people with a biologically normal moral sense, circumstances that trigger moral judgements and motivate ‘moral’ behavior are shaped by the moral norms of their culture and their experiences, good and bad, in that culture which affects which of those norms they internalize.
Those internalized moral norms become what people’s conscience tells them that everyone ought to do (a wonderful trick of our biology). These internalized norms can include admirable norms such as “Do to others as you would have them do to you” as well some that are repugnant to more enlightened perspectives such as “women must be submissive to men” and “homosexuality is immoral”.
In broad terms, these are the innate and experienced based components of each individual’s moral compass.
Work of the last 50 years or so in game theory and the science of morality points to the primary selection force for both the biology underlying our moral sense and cultural moral norms being the benefits of cooperation our moral sense and cultural moral codes produce. For example, the moral norm “Do to others as you would have them do to you” advocates initiating indirect reciprocity, arguably the most powerful cooperation strategy known. And the moral norms “women must be submissive to men” and “homosexuality is immoral” increase the benefits of cooperation in an ingroup by exploiting outgroups. Women are being directly exploited and homosexuals are being indirectly exploited as imaginary threats to the ingroup which can increase cooperation in groups under threat.
From the perspective of morality as natural phenomena, it is universally immoral to act to decrease the benefits of cooperation and universally moral to act to increase the benefits of cooperation without exploiting others.
For example, it would be immoral (from the perspective of morality as natural phenomena) to follow the Golden Rule when doing so would predictably decrease the benefits of cooperation as when “tastes differ”, in time of war, or when dealing with criminals. These are the circumstances when cultures commonly abandon the Golden Rule. Wonderfully useful as it is, the Golden Rule is not a moral absolute but only a heuristic (a usually reliable, but fallible rule of thumb) for increasing the benefits of cooperation.