A recent study may have solved the psychological mystery of why good people do bad things.

This question has haunted humankind for centuries, but these new findings offer new insights into what causes people to resist or give into temptation, the Society for Personality and Social Psychology reported.

"People often think that bad people do bad things and good people do good things, and that unethical behavior just comes down to character," said lead research author Oliver Sheldon. "But most people behave dishonestly sometimes, and frequently, this may have more to do with the situation and how people view their own unethical behavior than character, per se."

The experiment found participants who anticipated a potentially unethical temptation were less likely to give in to it. These participants were also less likely to support unethical behavior that had short-term benefits, such as illegally downloading copyrighted material.

"Self-control, or a lack thereof, may be one factor which explains why good people occasionally do bad things," Sheldon said.

The researchers divided 196 business-school students into pairs to act as the "buyers and sellers" of historic properties.  Half of the group was asked to write about a time in their lives when bending the rules had proved useful, helping to remind them of the potential benefits of ethical temptations; the other group was asked to remember a time in which a back-up plan was beneficial in the short-term.

The sellers were instructed to only sell the property to a buyer that would preserve the historic site; the buyers were told their client planned to demolish the historic buildings to build high-rises, but were instructed to conceal that information from the seller. Sixty-seven percent of the buyers in the control group (who wrote about ethical back-up plans) lied about the high-rise hotel plans, compared to only 45 percent of the buyers who had been reminded about temptation in the exercise.

In a second study involving 75 college students, participants were asked to flip a coin labeled "SHORT" and "LONG" several times to determine whether they would have to proofread a short or long passage of text. The students were split into two groups that performed the same writing exercises as the previous experiment. Half of the participants were also told that a person's "values, life goals and personality are stable," while the other half was told people's characteristics can change over the course of months.

The participants who were told to anticipate temptation and were told their characteristics were stable and indicated their future selves proved to honestly report the outcome of their coin flips, while those who were not encouraged to anticipate temptation and/or told their actions did not indicate their future selves were more likely to lie about their outcomes so they would not have to do as much work.

In yet another experiment that was performed online by 161 participants, those involved were found to be less likely to support unethical behavior in six workplace scenarios if they anticipated temptation and considered all of the scenes at once; as opposed to considering each scenario on a separate computer screen. These scenarios included behavior such as stealing office supplies and falsely calling in sick to work.

"Unethical behavior may not be experienced as something that needs to be resisted if people think it's socially acceptable or does not reflect on their moral self-image," Sheldon said. "People often compartmentalize their experiences of temptation, making it much easier for them to rationalize the behavior. They might say, 'Just because I took office supplies home for personal use one time, that doesn't mean I'm a thief.'"

The findings suggest that if one wishes to avoid unethical behavior, they should work to anticipate situations in which they might experience temptation and think about how caving in to certain temptations might influence their own long-term goals or fit into their moral code.

"You may not be concerned about getting caught or about your reputation if people found out, but you might be concerned about your own ethical self-image," Sheldon said. "Keeping such considerations in mind as one enters into potentially tempting situations can help people resist the temptation to behave unethically."

The findings were published in a recent edition of the journal Personality and Social Psychology Bulletin.