It was done to protect American workers and citizens. With the gold rush being in full power, there were more and more immigrants from China and it was decided to ban them for 10 years so as to prevent them from taking labor and gold away from American people who all moved westward inspired by the gold rush.