It seems to me that it was completely foolish for Italy to ally with Nazi Germany. What possible interest could Mussolini have in Hitler's irrational racial theories? Mussolini should have kept his country neutral and joined in at the last moment as the Americans did.
Yet, history tells me that he decided the opposite and went on to help the Nazis in wiping out the Jewish race.
Why?
Although you are correct that it was a foolish move on Mussolini's part to join the war, the decision to join the war on the side of the German in June 1940 had a certain logic to it from Mussolini's perspective, and should be understood from those terms. Italy's fateful leap on 10 June represented the intersection of three overlapping factors that had long been at play within Italian foreign policy: opportunism, ideology, and Mussolini's ambition to make Italy into a great power.
Pietro Nenni, an exile from fascist Italy, trenchantly Mussolini's analyzed Mussolini's invasion of France as the epitome of opportunism in 1940:
without sense, without possible justification, and without honour. Without sense, because no real Italian interests whatever were at stake. Without possible justification, because a German victory would impose on Italy, as on the rest of Europe, the intolerable and brutal hegemony of Hitler. Without honour, finally, because Mussolini is attacking a France already occupied and in deadly agony, thereby assigning to Italy the role of a jackal.
Although Nenni was an opponent of the regime, there was a great deal of accuracy in this statement. Mussolini had spent the winter of 1939 playing off the Germans and the Allies, the latter often represented by American intermediaries, for Italian belligerency. Once Mussolini realized that Germany's strength appeared ascendent in Norway and the initial stages of Fall Gelb, he decided to cast his lot with Hitler. Mussolini was quoted as saying that all he needed was a few thousand dead to earn a proper place at the negotiation table and for Italy to get both French territory and booty. There was much to suggest that Mussolini thought the war
at June 1940 was almost all but over and this would be a way for Italy to be on the winning side at the last minute. Ciano's diaries suggest that Mussolini was increasingly nervous about the war and he felt that for Italy to make no decision would have meant that Italy would receive nothing and lose its gains in the Mediterranean and Africa. This fear ensured that when Mussolini perceived that one of the warring powers was in ascendency, he would intervene at the decisive moment for Italy to gain the maximum amount of territory postwar.
This conceptualization of Italy as a "weight in the scales" was actually an Italian policy that had a long pedigree in both Fascist Italy and its liberal predecessor. Mussolini was not the first Italian leader to be likened to a jackal; Bismarck was actually quite fond of characterizing the Italians as opportunistic diplomatic scavengers. This opportunism reflected the fact that Italy was arguably the least of the great European powers and sought to maximize its limited military and economic clout by intervening at key points. Mussolini was very much aware of these restrictions and aggressively sought to have Italy break out of these bounds. Here Fascist ideology helped as it held that war and action could transcend reality and its restrictions. This had the effect of making Italian imperialism much more aggressive than prior Italian precedents, which were already quite ambitious. The Ethiopian War was emblematic of this new aggressiveness and assertiveness. One of the key tenets of Fascist ideology was that the new state was the reincarnation of the old Roman empire and one of the lessons of history was that power favored the bold. A daring attack and strike outwards into the Mediterranean would allow Italy to make this ideological picture a reality. Given that administrative anarchy bureaucratic dysfunction were the hallmarks of the fascist state, these sorts of ideas operated in an echo chamber which minimized any voices calling out for peace on the firm basis that Italy could not win a major war and would only become a subordinate to Germany.
Although Mussolini became Germany's sole ally in 1940, a crucial factor at play was Mussolini saw Italian belligerency as a means to transform Italy into a counterbalance to German hegemony within Western Europe. By eliminating the British and French presence within the Mediterranean when they were preoccupied with Germany, Mussolini felt that he could carve out a a large Italian sphere of influence in North Africa, the Balkans, and, eventually, the Levant. While this was done through the assistance of Germany, Mussolini conceived of entering in the war as escaping the shadow of his ally north of the Alps. One interpretation of Mussolini's aggressive foreign policy of the 1930s was that both he felt increasingly overwhelmed and sidelined by the ascendency of Hitler and Nazi Germany. Adventures like Ethiopia, intervention in Spain, his chaotic foreign policy at Munich were attempts by Mussolini to reassert control and regain the European spotlight he had enjoyed during the 1920s when fascism first made its name known. France's inevitable collapse, and Britain's strategic retreat made it seem like the golden opportunity for Mussolini to carve out a southern counterbalance to Germany's control over the northern and western Europe.
Obviously, none of this really worked out as planned and the Italy's war turned out to be the antithesis of what Mussolini thought it would be in 1940. Italy increasingly lost its freedom of action fighting a protracted war it was not prepared to fight. This led to a concurrent loss of prestige as the Italian armed forces did not cover themselves with glory in France, Greece, and North Africa. As Mussolini became more of Germany's lieutenant, Mussolini found himself increasingly less the master of his own house. German demands for Italian labor tread on Italian sovereignty and Italy had to implement more severe antisemetic legislation. While fascist Italy was far from judeophiliac, implementing the restrictions against Jews was not popular among prominent fascists like Italo Balbo. Furthermore, these wartime laws and restrictions racialized Judaism, which ran counter to Mussolini's prewar dalliances with antisemitism which often justified itself on religious grounds and justified restricting Jewish rights because Italy was a Catholic nation for Christians. The war also exposed the hollowness of fascism's rhetoric that it does not matter what one thinks so long as one obeys, as it highlighted the systematic corruption and incompetence of a state that allowed generals like Ubaldo Soddu, who spent his time on the collapsing Greek front composing film scores, to rise to prominent positions of authority.
Sources
Gooch, John. Mussolini and His Generals: The Armed Forces and Fascist Foreign Policy, 1922-1940. Cambridge: Cambridge University Press, 2007.
Knox, MacGregor. Mussolini Unleashed, 1939-1941: Politics and Strategy in Fascist Italy's Last War. Cambridge: Cambridge University Press, 1982.
Schreiber, Gerhard. Germany and the Second World War Vol. 3.-The Mediterranean, south-east Europe, and North Africa. Oxford: Clarendon Press, 1995.