I'm afraid I'm actually not that knowledgeable about the Nazi decision to invade the USSR. I don't know as much about the European front of WW2. My impression was that it was a mix of hardcore ideology (Nazi anti-Communism, racism, lebensraum, all of that) mixed with opportunism (the USSR looked weak and invading the USSR united many non-Nazi regimes behind Germany, like Romania, Bulgaria, etc.).
A Soviet-Nazi alliance seems totally implausible, but I wonder if it's possible for the Molotov-Ribbentrop non-aggression pact to more or less persist.
My impression is that Stalin wouldn't actually invade Germany, so everything that strengthens the public perception of the USSR's strength while weakening Germany's would increase the chance of Molotov-Ribbentrop surviving? Maybe even something like the Finns folding to Soviet demands in the Winter War and the invasion of Norway failing might lower the chances of the two from going to war against each other?