Maybe there's hope for humanity yet. As a species, studies have shown humans to be more willing to help strangers than other types of primates, and we exhibit less conflict within our groups compared with other animals too.

That's hard to believe if you switch on the news today, but new research suggests that we actually evolved the drive to be 'kind' in order to get access to more resources - and hints that it's not impossible for humans to become more welcoming to people of different backgrounds.

To figure this out, researchers from the University of California, Santa Barbara (UCSB) and the Max Planck Institute in Germany surveyed 150 farmers living in Bolivia – a particularly suitable sample for this study, seeing as they regularly need to work with others to protect their land.

"From maintaining access to territory, clean water and other natural resources – collaboration across group boundaries is crucial for many indigenous populations today," said anthropologist Michael Gurven from UCSB.

The goal of the study was to understand more about what might be driving this collaboration, and how we might be able to encourage other humans, who don't have farmland to protect, to be kinder to one another in future.

In total, 150 volunteers, taken from three different population sets of farmers, were asked to play a game where they could donate money to both 'in-group' strangers (from the same religious or ethnic background) or 'out-group' strangers (from different religious or ethnic backgrounds).

Importantly, the participants could see pictures of the people they were giving money to, and the recipients were given the names of the donors – even though this was just a game, that transparency helped reinforce the idea that these transactions could have a mutual benefit for both giver and taker.

The results showed that those who gave the most to out-group strangers were those who felt they were worst off, and who had the most to gain from new friendships.

People who had spent time living in different places and meeting a variety of people were also more generous to strangers of different ethnicities and religions.

This suggests that it's a need or desire for resources, plus positive and direct experiences with out-group people, that helps drive human generosity, trust, and tolerance.

"We have been too preoccupied with thinking about inter-group conflict," said one of the researchers, Anne Pisor. "We know less about why humans are so prone to inter-group tolerance and friendship."

"A better understanding of 'why' will hopefully allow us to better nurture friendships that transcend group boundaries – and maybe reduce the volume of conflict we see in the news."

While the researchers note that different communities are under different social and economic pressures – after all, many of us are no longer as dependent on collaboration to get what we need – the case of the 150 Bolivian farmers gives some clues as to why humans have been generous to outsiders in the past, and might be in the future.

We're more friendly to outsiders when we're more in need, but also when we understand them better – a lesson that's more important than ever in today's society.

The findings of the study have been published in Scientific Reports.