What would have to happen for the USSR to invade Germany?
When? In OTL 1940 or 1941?
I understand that they were preparing for war when Hitler invaded and that they would have attacked eventually.
Stalin told the Politburo in 1939 that his policy was for Germany to fight the western Allies as long as possible. It looks to me that he had plans for an eventual drive into middle Europe. The Red Army was enormous, with more tanks than the rest of the world combined. (Fact. Most of them were junk, but nobody knew that yet.)
Possible scenario 1.
The Allies re-break Enigma a few weeks earlier in 1940. This provides clear warning of the invasion of Norway, which they defeat. Hitler postpones the attack on France for several weeks. In the meantime the Allies persuade Belgium to cooperate (the example of Norway).
The Allies also build up air power in France (additional production by France, more of Fighter Command shifted from Britain as after Norway there is no fear of German invasion).
Hitler attacks in July 1940; the campaign is a very limited success, with the Germans checked outside Brussels and in the Ardennes. Then the Germans turn SE, flanking the Maginot Line, and win a major victory, though they still are nowhere near Paris when winter sets in. But it's enough to hold off German defeatists.
In 1941, the Germans renew their attacks in France, and Hitler persuades Spain and Italy to join in. (Hitler cleverly maneuvers Franco into stating his conditions before Spanish witnesses - then says "OK" to general rejoicing.) France collapses.
However the Allies hold out in North Africa - having complete naval superiority. Later in 1941, the Axis invades Morocco and conquers French North Africa by mid 1942. (The Allies having taken Libya and East Africa.) The German armed forces have been heavily engaged in all this fighting, and Hitler hasn't even considered striking east yet.
But Stalin sees his chance. He invents a casus belli and sends the Red Army west in July 1942. (He doesn't want to wait for Germany to redeploy to the east...) Also the USSR goes into Romania to cut off Germany's oil supply.
How does the war play out from there? Well, Germany is going to be hit hard. The Red Army will be much better equipped than in OTL 1941. OTOH the Red Army will still be half-lobotomized from the Great Purge, with thousands of colonels and generals promoted beyond their military qualifications for political reliability.
There will be some initial Soviet success, but heavy casualties on both sides, and the Soviets won't be able to sustain their advance due to logistical weakness (as in OTL throughout the war). Germany will rally and begin a massive pushback; the overextended Soviets will get badly cut up.
But the Germans won't deliver a knockout blow either - they'll have taken heavy losses, besides the attrition from the fighting in the west, and they'll be really short of fuel.
Meanwhile Britain and the French Empire will try to push back in Africa, keep Europe blockaded, and bomb Germany.
This slugging match could go on for quite a few years.
Note that I've not mentioned the US or Japan. Assume they both remain neutral. That cuts out Lend-Lease aid, which was really quite important to the Soviets. Without Lend-Lease and a major Western Front, I don't think they would have defeated Germany. Nor been defeated, either.