Their navy seems to have been effectively neutralized in the early years of war, and suffered a major defeat at the Battle of Taranto. Why were they not able to keep up with the British Royal Navy's mediterranean fleet, despite being numerically and technologically comparable?
There is a thing in Naval strategy called a 'Fleet in Being'. A Fleet in Being is a strategic threat to the opposing force merely by existing. It forces the enemy to account for the potential of a formidable fleet to sail out of port and attack at all times. They have to constantly be on the look out, even if you never actually sail the fleet out. It's simply too risky not to be prepared for the possibility.
This can be a potent strategy simply because it ties up resources that could go elsewhere, or make certain sea lanes completely unfeasible. In WWII, the Regia Marina employed this strategy to limit the Royal Navy's options and keep Malta isolated (Malta being a strategically significant island in the sea).
Why employ this strategy, which is predominantly about not fighting?
Simple! The oft overlooked and underappreciated art of logistics.
Because Italy completely lacked the industry and raw materials to replaces losses in war time. While the Regia Marina may have been the equal of the Royal Navy in the Mediterranean sea in terms of numbers, it was not in terms of total power. If a sea engagement occurred and the Royal Navy lost, they could simply replace those loses with other ships. Meanwhile even if Italy won it would be unable to replace losses. Engaging in a battle was risky. If the fleet was too damaged, you could lose the strategic value of the fleet existing for negligible short term gains.
In essence, trying to employ the Regia Marina as a combat force directly was a losing proposition. Even if you won, you risked losing the ability to threaten the British with the fleet while the British could simply send in more ships. Even after the British success of Taranto, the Regia Marina was still operating as a Fleet in Being. The British had to keep being wary of potential attack for years.
Frankly speaking, on this one front nothing went wrong. The Regia Marina was employed in the most effective way it could possibly be employed. It was no match long term for the Royal Navy, could not replace it's losses, and was at its most threatening as a strategic resource just by existing.
It's also worth noting the Kriegsmarine used this same strategy with it's surface ships after the sinking of Bismark. The battleship Tirpitz was moored in Norway for most of its wartime life, solely to threaten naval shipping from it's position.
Aside from the above excellent response, I'd add that another issue was the actual construction philosophy of the Regia Marina.
Because the Regia Marina was fully aware that it could not match the Royal Navy in open combat, ships were constructed in a way which backfired horribly. Basically, the Regia Marina chose to build faster lighter ships but armed with longer range guns. This way the Regia Marina could, theoretically, engage Royal Navy vessels from a distance before rapidly breaking off. This in practice worked horribly because it did not account for the threat the RAF could pose to Italian vessels.
Things weren't really helped by the fact that although some cutting edge technology had been pioneered in Italian universities, the High Command had little interest in these new technologies. Stuff like sonar or radar, which you'd think would be vital in naval combat was not that widely used at all by the Regia Marina. This is very symptomatic of the Italian military leadership on general, it was very conservative backward looking and in many cases still stuck in First World War thinking.
And this leads to another point, ineffective leadership. This went from the aforementioned High Command not making use of fundamental new technology to individual vessel commanders who were not unknown to make very stupid and basic mistakes.