Before World War I broke out in 1914, Italy had been allied with Germany and Austria-Hungary, so, at first, it seemed likely that Italy would join the Triple Alliance. Mussolini, then the editor of a socialist newspaper, was eager to keep Italy out of the war, as he saw the war as an effort by capitalist bosses to use the proletariat as cannon fodder. By 1915, though, Mussolini's views had changed, as he saw the war as what he called "a great drama." At first, many socialists in Italy sided with Mussolini in staying out of the war, but, like him, they began to gravitate towards intervention (even as he was kicked out of the Socialist Party in Italy).
The Italian government began to see the war as a way to gain more territory. In the Treaty of London of 1915, Britain agreed to grant Italy territory in the Adriatic if they became involved in the war, so Italy joined in April of 1915, entering the war on the side of the Triple Entente—Britain, France, and Russia. Britain and its allies wanted Italy to help start a southern end of the Western Front to further weaken the Triple Alliance.
From 1915 to 1917, Italy made very little progress into Austrian territory, and Italian troops were defeated soundly at the battle of Caporetto in October of 1917, resulting in the deaths of 300,000 soldiers. Over 600,000 Italian soldiers died in the war, and the government was in debt as a result of the fighting. In addition, the Italians got very little of what they had wanted at the treaty negotiations in Versailles in 1919, giving rise to a sense of wounded pride and a current of nationalism in Italy after the war.