And they weren't a chaotic low spirited horde, they we merely an unmotivated, disorganized army led by an incompetent high command.
Okay, let me explain Glantz and other modern historians in my own words.
Initially german forces were using panzer units as main strikeforce with infantry units acting as slow rubber eraser. Initial borderline panzer battles were catastrophic for Red Army tank units which were acting without ability to maintain and repair their machinery. But this tank battles allowed the Red Army to partly draw the infantry formations out from the encirclements and form an uninterrupted line of defense again. Therefore, these tank units died but were also used to win some time to spare.
After the first six weeks of the campaign and surprise wore off, the Soviets reacted well and they had the men, machines and resources to respond. They've playing the game of attrition. By the time Germans reached the Smolencks area, their fast (armored, mechanised and motorised) forces outpaced foot infantry forces. This in turn prevented Germans from effectively encircling Soviets as they simply lacked infantry to do it properly.
The Soviets managed to all but halt the blitzkrieg by launching a series of counterattacks that forced the German Army Group Center to pause. These Soviet offensives, there were four of them, inflicted a series of attritional battles that had a severe depletion effect on Center's infantry formations. This in turn forced the Panzer and motorized elements to act as defensive screens in their own right, holding the line of the "outer encirclement," a function that mobile forces are not suited for.
The resistance encountered in the Smolensk region convinced Hitler to alter his plans for the campaign going forward. He ordered the Smolensk roadblock bypassed and sent General Hoth's panzergruppe north to assist Army Group North in its drive to Leningrad, and he ordered General Guderian's panzergruppe to drive south. The latter action pushed aside a few more Soviet Armies and upon a link-up with Army Group South, another Soviet force was encircled in the vicinity of Kiev, netting another 600,000 Soviet troops in the bag. This diversion of forces from Army Group Center to secure the flanks represents the second phase of Operation Barbarossa. Despite this, soviet forces at the north were able to cling upon the Ladoga-Novgorod fortified zone and hold off the initial attempt to take Leningrad swiftly.
Third phase naturally occurred when the flanks of AG Center were secured and the final thrust on Moscow, Operation Typhoon, began. However, Soviets were able to launch Elnya counteroffensive once more during the August 1941 and when Typhoon started, it was already into the deteriorating weather season, german resources were severely depleted, Soviet were able to relocate industry and mobilize the economic system (because of time spared by sacrificing tank reserves at the initial phase of war). Typhoon exhausted and failed with the Kremlin in sight and Germans suddenly found themselves on the brink of defeat with supply lines overstretched and reserves depleted once again.
On the other side Soviet high command convinced itself that Germans, Army Group Centre in this case, was so overextended that one big offensive will collapse them. While Germans were overextended and their logistics were strained they were nowhere near breaking point and local success was just that, local.
The military strategy Stalin, the Stavka, and Western Main Direction Command pursued was far more sophisticated than previously believed; Stalin, the Stavka, and Timoshenko's Western Main Direction Command employed a strategy of attrition designed to weaken advancing German forces; This attrition strategy inflicted far greater damage on Army Group Center (wear and tear, and losses of 60% of German armor: much of this was permanent loss, and never repaired and replaced back up to original strength) than previously thought and, ultimately, contributed significantly to the Western and Kalinin Fronts' victories over Army Group Center in December 1941 (the greatest one: Time (2 months of stalling)).
If it was purely an ASB-luck and Soviets were able to do this in contrary to their own moronic High Command, and despite their army was 'an unmotivated, disorganized army led by an incompetent high command' then maybe all of us should go straight to the land of acid butterflies and fairy ponies.
Vital opportunities were thrown away by Wermacht, never to return.
I recommend you to read Glantz. This series is head and shoulders better and more detailed than other books on Barbarossa.