Speaking of Stalin, it is impossible to give a concrete and accurate answer, since it still causes historians to have absolutely polar and ambiguous opinions. We, not seeing this all with our own eyes (and thank God), now we can not give a concrete assessment of someone’s decisions and call them right or wrong.
Nevertheless, the 1939 Molotov-Ribbentrop Pact significantly delayed the beginning of the war, and the non-aggression pact with Japan significantly reduced the threat of war on two fronts.
Also, the figure of Stalin and his public actions during the war had a huge positive moral impact on the Soviet people, inspiring confidence in the ultimate victory.