I agree that religion, fundamentalist religion in particular, is part of it. Fundamentalist sects tend to view critical thinking and reasoning as dangerous, as something to be suppressed at all costs both in education and within themselves, because those things create doubt and dissent. They begin with the belief that an authority figure knows the absolute truth of the universe, and anything that contradicts their words must, therefore, be false, no matter what evidence exists. The authority figure defines what truth is, and anything else is false.
That's how people can believe "alternative facts", how they can look at those photos of the inauguration and say that they see more people at Trump's inauguration than Obama's when that's plainly not true - because they view authority figures as more reliable sources of truth then their own eyes and ears.
But I don't think that explains it all. There are plenty of religious people who don't have that rigidity, and plenty of secular people who are racist, sexist, homophobic, etc.
I think that at least much to blame is working- & middle-class white Christian resentment over the erosion of their cultural dominance and at the upending of the traditional (but unspoken) American class structure.