The Taft-Hartley Act was passed because people in the country as a whole felt that labor unions had gotten too strong in the decades before the passing of the law.
Prior to the Progressive Era, labor unions in the US were quite weak. But then, the Progressives started to give labor more power. This came to a head in the New Deal era when Congress passed the Wagner Act. This law had the government giving an unprecedented level of support to labor.
Right after WWII, there were a series of strikes that hit the US. By this time, the Republicans had gotten control of Congress. Because of this, and because there was broad public support to rein in the unions, they passed the Taft-Hartley Act.