As far I know, it's due a lot of reasons. I'll list what I know.
1)The Italian people wasn't too enthusiast of the war, and apparently even disliked its ally: I remember listening a record of Mussolini announcing the declaration of war, and when he announced it was against France and Britain he got
booed.
2)As already said, the Italian army had low-quality equipment (bad tanks, bad rifles, bad everything but bayonets and mortars), and often not enough of it. Steps were being taken to correct this, but they were too little, too late (a good example comes from the Carcano rifle, whose ammo tended to overpenetrate and didn't make enough damage unless it hit a vital organ: the problem was known since WWI, but a larger caliber round and the relative Carcano variant started being fielded only in 1938, and it was all aborted when Italy entered the war because there wasn't enough of the new round), and sometimes failed miserably (see the Fiat-Revelli Modello 1935 and Breda Mod. 37 machine guns: replacing the older Fiat-Revelli Modello 1914, they were overcomplicated and only slightly less prone to jamming than the older weapon).
3)The officers of the Italian Army were bad: with few exceptions, the higher was the rank the higher was the chance they got the rank due nepotism and corruption. To make just one example, Pietro Badoglio had been one of the responsibles of the defeat of Caporetto during WWI (arguably even more than Cadorna: Badoglio was supposed to defend a forced chokepoint with overwhelming artillery, but due his orders to not fire unless ordered otherwise by him the artillery did nothing), but had escaped prosecution and was even chief of staff of the armed forces from 1925 to 1940.
4)The Italian army was poorly trained for WWII standards. Well-trained for WWI, and its cavalry charges were downright lethal (the regiment Savoia Cavalleria still brags about Isbuscenskij during WWII with good reasons), but all of its training and equipment was geared to defend and assault trench lines.
5)Italian supply lines were poor. The army had little trucks and many mules and camels, and the merchant navy had to deal with minefields and the strange ability of the Royal Navy to know almost everything.
6)Due all of the above, the morale of the Italian Army was at an all-time low, with the only exceptions being only the elite corps (Alpini mountain troops, the famous Bersaglieri, the recently reactivated Arditi assault troops, the Milizia Volontaria per la Sicurezza Nazionale (AKA the original Blackshirts) and the Carabinieri (who doubled as the universally loathed military police and provided the royal guard)). As a consequence, the line troops mostly fought half-hearted, and in spite of occasional acts of valor (like the aforementioned Charge of Isbuscenskij or the sacrifice of five Italian divisions (including the Ariete tank division and the Folgore parachute division) at El Alamein, that fought to the last round covering Rommel's retreat) they tended to retreat as soon as they were given the occasion.
7)Interservice rivalry: the Navy and the Air Force loathed each other, and tended to not collaborate. Friendly fire among the two were fairly frequent.
The Italian Navy wasn't up to task. While powerful and possibly able to give the French Navy a terrible beating, the enemy was the Royal Navy, that seemed specifically created to take advantage of both the Italian strengths (very fast ships) and their weaknesses (paper-thin armor, they were led from Rome until the start of the engagement). A good example comes from the battle of Cape Spada: in that engagement two Italian light cruisers (designed as destroyer hunters, using their high speed to keep pace with enemy destroyers and then sink them with their superior firepower) engaged four British destroyers but were led in a wild goose chase and brought before a fifth destroyer and the Australian light cruiser
HMAS Sidney (more armored than the Italian ones and with comparable firepower), resulting in one Italian cruiser sank and the other damaged and forced to retreat.
9)The Italian Navy had no carriers. That meant they depended from the Air Force for recon and air support, and only contributed to interservice rivalry.
10)Poor coordination among different branches, as, apart special cases, all of it had to pass from the Supreme Command. Thus a request for air support from the Army or the Navy had to be made to Supermarina (Navy supreme command) or Superesercito (Army supreme command), that would pass it to the Supreme Command, who would analize it and pass it to the Air Force, that regularly arrived on the battlefield too late. Information from air rec went from the same route, slowing operations.
11)Somehow the Royal Navy
always knew what the Italian Navy planned. That led to paranoia and low morale, and until 1974 and the declassification of ULTRA it was considered a fact that there were traitors in Supermarina.
12)Mussolini was so sure that the war would end in a couple months that a good chunk of the merchant navy remained outside of the Mediterranean Sea and eliminated from the war (either sank or captured by the British or interned in neutral ports), worsening the logistical nightmare.
13)The Italian Air Force was unable to tell the Italian ships from the British ones, leading to the aforementioned friendly fire incidents when they came to support it (the Air Force would attack the first force they saw, that would always fire back. More often than not it was Italian ships that were being attacked and fired back).
14)When the Air Force actually got the right target, their bombs were not up to task (they got the nickname 'cowshit' from the Italian Navy for this reason).
15)The Air Force was underequipped due antiquated thinking in the Supreme Command: while they had a magnificent medium bomber/torpedo plane in the
SM.79, the main fighter was the
CR.42, that could be easily handled as long as the enemy pilots remembered to not engage in a dogfight.
16)Italian replacement of the antiquated CR.42 with better fighters was slow, as the new Italian fighters, while capable, were overcomplicated and depended on German-made engines.
17)Italian industry was not up to task. While greatly grown during Fascism, it was still not enough to produce everything needed for a modern war, and suffered from shortage of strategic materials like steel, coal and, in a lesser measure, oil (extraction of petroleum in Libya was still starting).
18)Italian industry had a penchant for overcomplicating things (hence the problems of Italian machine guns and modern fighters) and low quality control (hence the problems with reliable ammo).