Knowing what is morally right isn't really that hard. In fact, many three-year-olds not only know what is wrong and right, they are willing to put themselves on the line to call out bad behavior.

An ingenious study by researchers at New York University found that children as young as three are willing to punish others' bad behavior, and they are even willing to pay a price for their whistle-blowing if need be.

The findings offer an explanation for why some people risk arrest protesting issues that may not affect them directly.

“Morality is about more than just doing good oneself — it is also about encouraging good behavior in others,” said Daniel Yudkin, lead author of a study designed to shed light on our willingness to punish “bad actors” who haven't harmed us directly, in a statement. The NYU team decided to focus on children, figuring that how we think about punishment early in life might shed light on the psychological processes inspiring the need to hold people accountable.

The study involved more than 200 children, ages three to six, who were recruited at the Children's Museum in Manhattan. Each child was brought individually into a classroom that had a large red slide in the corner and allowed to try it out, something that afterward they all said they enjoyed.

Then they saw a video featuring a girl named Stacey who tore up a drawing that someone else had made. After seeing the video, they were told that Stacey would be coming to the room later in the day to play on the slide.

All the children were given a sign that said “Open” on one side and “Closed” on the other. They were told that if they put up the “Open” sign, they could slide on the slide later, and Stacey could too. But if they put the “Closed” sign up, Stacey would not be able to use the slide, but neither would they. So punishing Stacey would come at a cost — it would also mean they couldn't enjoy the slide.

About half the children were willing to punish Stacey by closing the slide, and the percentage willing to do so went up with age. Five- and six-year-olds were three times more likely to punish her as three- and four-year olds.

The researchers added another experiment to better understand what would make children more likely to punish someone. They randomly assigned kids to different conditions. In one, a group was either told Stacey was a member of the Children's Museum or that she was a member of the Boston Museum, an outgroup.

Another condition in which some children were given sheriff's badges was created to see if being put in a position of authority made a difference in how likely the children were to say Stacey should be punished.

The results in the first condition were surprising. Usually, studies find that people treat members of outgroups more harshly, but in this study, kids were inclined to go easier on the Stacey from Boston. The one exception was among younger children who had been given sheriff's badges. They were more likely to exercise their authority to punish her.

This “in-group policing,” the researchers concluded, made people willing to take more responsibility for making sure that others were behaving well.

The findings suggest one reason why some people risk arrest protesting issues that don't necessarily affect them directly, the researchers say. The exact explanation for this behavior, though, is not yet clear. It may be that people want to look good to others, or they are simply wired to uphold moral rules.

“Of course, we cannot tell for sure whether this behavior is innate or learned in the first few years of life,” Ludkin said. “But it does add to growing evidence that, at a very young age, humans are predisposed to do good themselves and encourage good behavior in others.”

The study is published in the Journal of Experimental Psychology.