Germany's biggest fear leading up to WWI was having to fight a two-front war, and though they ultimately won in the East it all ended in disaster. The Nazis clearly worried about the same dangers, so they did the smart thing and signed a non-aggression pact with Stalin before WWII.
In 1941, the Nazis were at peace with the USSR. They were fighting plenty of other battles in the West, and with events like the Battle of Britain it was becoming clear that despite being the most powerful nation in Europe they couldn't expect certain victory in everything. Hitler was many things, but stupid wasn't one of them.
Maybe the Nazis were doomed to fight the USSR eventually, but why did they decide to commit so many resources to the East in 1941? Why not focus attention on winning in the West, and wait to face the Soviets until they had peace and could devote themselves solely to Russia?
Partial answer here. Ideology and distrust was certainly one reason but in the opinion of some scholars the economic aspects were every bit as important.
Basically for ressources.
The original plan of Hitler was to add every Germanic nations to the Reich to unite Aryan peoples and to conquer the Eastern Europe and send Aryan to settle the place. The local populations would be killed in major part and a small number of them would be kept as slaves to work in the farms of the Aryan settlers as slavic populations were seen as hardworking and docile contrary to jews. Ukraine and its huge fertile lands was to be at the center of the dispositive and would have been used to feed the Reich.
Hitler's projects therefore meant that he would clash with USSR soon or late. Add to that the profound dislike of Hitler for communism and you have your war.
Hitler was many things, but stupid wasn't one of them.
Hitler war a brillant orator with a fanatical belief in his own invincibility. Was he stupid? It depends on your definition of stupid but Hitler was definitly stupid to some degree. Hitler believed in a lot of stupid shit and thought he could not be killed (this belief came from him surviving several life threatening situations including a gas attack in WW1 and several assassination plots later in his life).