Question: A genetic mutation is causing people to have a [cerebrovascular accident](https://en.wikipedia.org/wiki/Stroke) as soon as they think or do something considered immoral by the society in which they live. 

For instance, in most countries, in the following situations, these people would immediately die of stroke:

* Someone sees a nice watch and he thinks of stealing it.
* Someone is very angry, he thinks of hurting someone else.
* A man sees a women and thinks of cheating on his wife.

In some societies where people have different education and moral values, a similar action would not provoke the death. 

* In a tribal village, killing someone else might be considered brave, so thinking about doing it will not provoke a stroke.
* In a terrorist group, thinking of killing your enemy is considered your mission, so it will not provoke a stroke.

While in some other societies where moral rules are more precise, people would die for "minor" thoughts.

* In a religious village, a woman dies when she starts gossiping or judging others.
* Someone dies because he spits on the sidewalk.

All humans have this mutation, it has been triggered by global warming and is irreversible.

What could happen in such a world? Would most people die because of the rule of society? Would small group of link minded individuals flourish? Would people start moving towards other countries to be able to think freely? How could one control its thoughts to avoid dying?

Answer: 
Natural selection:

Here's the crucial part: Most moral systems include a clause that makes it immoral to doubt the moral system.

Result: As immoral thoughts are suddenly deadly, natural selection raises it's ugly head and starts thinning out those who are unable to only have "pure" thoughts. Large parts of society die.

Assuming we don't immediately drop under the repopulation limit, the survivors eventually start rebuilding society. Since society has collapsed enough for normal moral values to become lost, new morals form.
Natural selection again kicks in, favoring those societies with clearly defined, but easy to follow morals (= less strokes) over others. "Evil" societies probably wouldn't strive, due to the inherent problems with maintaining a ordered evil society.

Society reforms, globalization happens, morals shift rapidly, we start the circle anew.

---

Follow up question: What would happen if someone had warned us beforehand?
Your question sparks fear in me. It could very well turn the world into a setting like a zombie apocalypse, albeit without zombies. I believe immorality is not just thinking of sin, but as giving in to that temptation and acting on it. Your example seems rather 'unforgiving,' and in my belief, would most undoubtedly lead to the deaths of all humans.

However, practitioners of monasticism, altruism and asceticism might have a longer lifespan.

You may also need to consider 'universal sins.' For example, killing your neighbor out of boredom is, to my knowledge, sinful all over the world.