The Palmer Raids were caused by two main factors. One of these was domestic while the other was international.
On the international scene, there was the Russian Revolution and the general rise of radical political ideologies in Europe. The Bolsheviks had, of course, come to power in Russia in 1917. They had fairly strong support in other countries as well. In addition to this, communism and anarchism had been getting more popular in Europe in the early decades of the 20th century. The rise of these radical political ideologies worried Americans. They were afraid that the ideologies might spread to the United States.
In the US, there were things taking place that seemed to confirm these fears. There were anarchist bombings around the country, one of which was aimed at Attorney General Palmer. There were major strikes around the country in 1919. There were smaller, but well publicized, incidents such as the robbery and murder for which Sacco and Vanzetti were eventually executed. These sorts of incidents made it seem as if American fears of rising radicalism were warranted.
These were the main factors which caused the Palmer Raids.