historically the entry of Italy closed the Med for UK commercial shipping for most of the war? (my reading on the subject) guess the question would be the costs of Axis (Germany) conducting the North Africa campaign vs. that benefit to them (longer, more perilous route)
It was very hard for the Allies to send shipping into the Meds for the start of the war, not enough protection. The Italians tried, but failed to prevent British possession in the Meds from being supplied from the sea eventually. Most notably Malta which was supplied by a couple of succesfull convoys after 1941 which the Italians and Germans failed to stop. The Italians had a fleet-in-being, meaning their fleet was mostly kept in port and acted as a threat to the British fleet, which did sail the seas and supplied their possessions with their aircraft carriers. They never actually create a blockade to stop allied shipping from entering the Meds. If Gibraltar would be in Axis hands however, an actual blockade can be started.
The biggest merit they would get of course from even a short blockade of the meds to allied shipping is the possibility of Malta falling and being occupied, opening up opportunities to take control of the meds fully, with the next target the Suez canal. This will make sailing the meds for the Allies a lot more dangerous as there is less coverage by air.
Taking Girbraltar is possible for Spain, but their control of it would indeed be very short and only help the Allies win the war. The Italians, i'm not sure they had the capabilities to actually invade Gibraltar from their positions, even if they would use their full fleet. It would just endanger their fleet from being sunk and become useless in one failed attempt. They played it safe, which was smart.