How does people's sense of right and wrong affect their behavior?
This is an interesting question which seems that even the experts are still investigating it to a degree.

Take a look at the links I provide in this answer and look at the conformity studies like the Milgram Experiment and the works of Dr Phil Zimbardo with his Stanford Prison Experiment and his book on The Lucifer Effect (a study of the Psychology of Evil and heroism) etc.

Stanley Milgram tested earlier conformity studies by Solomon Asch to see what extent the experiment can reach.

It seems that even though there are a few who are an exception, there are those with high moral standards who can be swayed into doing something bad.  Especially when their actions are "justified" by someone in authority or seem to have more knowledge of the situation.

There seems to be a fine line which can be very blurry to a degree.  For a rather pessimistic view on society have a look at this article.