There are plenty of reasons Trump was elected, but the following are two big ones.

Illegal immigration. While many Trump supporters are racists and bigots, it's not racist to simply be against illegal immigration.  Many ordinary Americans, including many Dems simply would like their government to enforce immigration laws.  When these workers hear many Democrats discuss immigration what they hear is people who seem to believe in open-borders and act as if the law of supply and demand don't apply to labor. You can support a pathway to citizenship for the undocumented immigrants who have made lives here and still support legal hiring practices and secure borders.

Islam. In their quest for inclusion and tolerance most liberals refused to make the connection between actions and beliefs. So, as Muslims continue to carry out horrific attacks and oppress women around the world, they understandably believe that liberals refuse to accept a reality that's required to address the problem.