Soon after World War II, amidst the devastation and poverty of postwar Europe, communist rebellions broke out in Greece and Turkey. This immediately got the attention of President Truman, as he became aware how aggressive the Soviet Empire was going to attempt to expand communism in the region and the world, and he moved to stop the rebellions with $900 million in military aid.
The Marshall Plan had the same goal but more peaceful means. Europe needed to be rebuilt, that was a fact. But a Europe which witnessed a democratic nation, the US, financing and rebuilding their streets, buildings, dams, bridges, roads and schools would have the best possible public relations effect. The Soviets would look aggressive (because they were) and the US would look generous and friendly. A more stable economy in Western Europe was the result and communism had a much more difficult time taking root there.