out of moral obligation
He helped his neighbour out of moral obligation.
—Why did you do it? —Out of moral obligation, I couldn't ignore it.
He felt the moral obligation to tell the truth.