Cognitive dissonance arises because people want to protect their world-view or self-concept. Even people well versed in science may deny the facts in favor of false beliefs.
The question spans three levels of grossly different arenas of research:
[Why so people strive for internal consistency  at the expense of truth?
- This is a matter of Psychology and perhaps even Philosophy
- [What are the] mechanisms on the neuron-level that resist the rewiring of the brain?
- This steps all the way down to cellular and molecular neurophysiology
- [What is the selective advantage] from an evolutionary perspective?
- This ramps the question to an evolutionary time scale
I'll take a bash at this question from a more Psychological approach, mainly because the other two angles do not seem fruitful to me as
- Rewiring (Neurophysiology) is a term often used in terms of gross plastic changes in the brain, such as that occur during intensive training (e.g. when folks learn to juggle), or after a stroke.
- Evolutionary reasons seem far-fetched. The development of higher cognitive processes may have aided in our rise to domination. For example, the forging of social structures and accompanying cultural development may have be the foundation to the cross-generational transfer of intelligent tool-making and so forth. Such complex behaviors spanning millions of years may have led to other behaviors like the denial of facts. Such behavior may not be evolutionary beneficial, but a collateral development. You have to realize not every feature is perfect. On the contrary. The regenerative power of many a cell in the body allows for wound healing, but also gives rise to cancer. Aggressive immune systems defends us during our life against countless enemies, including cancer cells, but when going haywire it leads to devastating auto-immune diseases like multiple sclerosis. Likewise, intelligent behaviors may result in aberrant thought processes, like believing and holding on to something as to be true it, while the facts challenge that idea. Now why does that happen?
- The Psychological approach seems most feasible. Denial of scientific facts to support ones own aberrant world views has been in the news a lot of late, sadly - Trumping the truth! (Shermer, 2018). Shermer says
[A]ntiscience attitudes are formed in very narrow cognitive windows—those in which science appears to oppose certain political or religious views.
For Republicans, the more knowledge they have about climate science the less likely they are to accept the theory of anthropogenic global warming . People with more knowledge only accept science when it doesn't conflict with their preexisting beliefs and values .
In another of his excellent columns, Shermer (2017) names a list of more examples:
- Creationists  dispute the evidence for evolution in fossils and DNA because they are concerned about secular forces encroaching on religious faith.
- Antivaxxers distrust big pharma and think that money corrupts medicine, which leads them to believe that vaccines cause autism despite the inconvenient truth that the one and only study claiming such a link was retracted and its lead author accused of fraud.
- The 9/11 truthers focus on minutiae like the melting point of steel in the World Trade Center buildings that caused their collapse because they think the government lies and conducts “false flag” operations to create a New World Order.
- Climate deniers study tree rings, ice cores and the ppm of greenhouse gases because they are passionate about freedom, especially that of markets and industries to operate unencumbered by restrictive government regulations. Obama birthers desperately dissected the president's long-form birth certificate in search of fraud because they believe that the nation's first African-American president is a socialist bent on destroying the country.
The term here was launched after the description of a UFO cult that predicted the arrival of the mother ship Shermer (2017).
When that failed to arrive at the appointed time, instead of admitting
error, members of the group sought frantically to convince the world
of their beliefs, and they made “a series of desperate attempts to
erase their rankling dissonance by making prediction after prediction
in the hope that one would come true.” Festinger called this cognitive
dissonance, or the uncomfortable tension that comes from holding two
conflicting thoughts simultaneously.
Cognitive dissonance is:
[T]he mental conflict that occurs when beliefs or assumptions are contradicted by new information. The unease or tension that the conflict arouses in people is relieved by one of several defensive maneuvers: they reject, explain away, or avoid the new information; persuade themselves that no conflict really exists; reconcile the differences; or resort to any other defensive means of preserving stability or order in their conceptions of the world and of themselves.
Cognitive dissonance - why (Shermer, 2017)?
Because [the facts] threaten their worldview or self-concept.
Science denial, for example is not typically rooted in blanket anti-science attitudes. Instead, people's denial of scientific evidence is based on motivations other than finding truth, such as protecting their social identity. It appears that the more science-literate people are, the more strongly they hold to their beliefs — even if those beliefs are incorrect. So it hasn't anything to do with education. It's about ones owns beliefs and holding on to them (source: Live Science).
- Shermer, Sci Am, January 2017
- Shermer, Sci Am, January 2018