Answer: The inability of the Soviet Union to succeed in its goals of advancing communism in Afghanistan showed its weakness, and the expense of the war contributed to problems back home in the USSR.
Additional context: The Washington Post reported in 1988, after the USSR had been struggling in its war with the Afghans for nearly a decade: "Afghanistan is Russia's Vietnam -- possibly with even greater consequences for the Soviet Union." Much like the United States struggled in unfamiliar territory against a highly motivated enemy in Vietnam, the USSR found it could not win in Afghanistan. And the help offered to Afghan fighters by the United States was a sizable factor also in strengthening the Afghan resistance. The book, Charlie Wilson's War by George Crile III, published in 2003, details how the US covertly carried out its support of the Afghan mujahideen. Afghanistan served as a proxy war in which the US supported forces which opposed the USSR, without itself going directly to war against the USSR.