Morality consists in the set of rules, governing how people are to treat one another, that rational people will agree to accept, for their mutual benefits, on the condition that others follow those rules as well.
Social contract theory holds that it is right for me to act according to a moral rule if rational people would collectively accept it as binding because of its benefits to the community.