I suggest reading up on Kant's categorical imperative
Categorical imperative - Wikipedia
to quote:
A categorical imperative, on the other hand, denotes an absolute, unconditional requirement that must be obeyed in all circumstances and is justified as an end in itself. It is best known in its first formulation:
Act only according to that maxim whereby you can, at the same time, will that it should become a universal law.[1]
Kant expressed extreme dissatisfaction with the popular moral philosophy of his day, believing that it could never surpass the level of hypothetical imperatives: a
utilitarian says that murder is wrong because it does not maximize good for those involved, but this is irrelevant to people who are concerned only with maximizing the positive outcome for themselves. Consequently, Kant argued, hypothetical moral systems cannot persuade moral action or be regarded as bases for moral judgments against others, because the imperatives on which they are based rely too heavily on subjective considerations. He presented a
deontological moral system, based on the demands of the categorical imperative, as an alternative.