Operation Felix was the seizure of Gibraltar (a British naval base at the tip of the Mediterranean Sea) by the Nazis during World War 2. The Nazis believed if they could take control of Gibraltar, which was strategically important, they could take control of the Mediterranean and invade French North Africa. It seemed like the plan was going to go forward, but it was stopped. What happened?
In short, without wholehearted Spanish support, taking Gibraltar would have cost too much militarily and Franco wanted the rock for Spain. Having it change from British hands to German ones really didn't serve Spanish interests. Further, Franco was concerned about losing the Canary Islands to the Royal Navy if Spain did not remain neutral.
There were quite a number of reasons why Operation Felix (and later Felix-Heinrich) was not carried out, most of them covered in the Wikipedia article. These are elaborated on and supplemented by the links provided in the comments on the OP and on Tomas By's post. There is little point in repeating them here, but one point worth emphasizing is that Franco wanted Gibraltar under Spanish control, not German.
The then Spanish Interior Minister Ramon Serrano Suner
recalls that after the downfall of France, Franco and virtually all his Generals had 'blind faith' in a German victory and were impatient to occupy the Rock
Source: Joe Garcia, Operation Felix (my highlighting)
On the other hand, according to the historian Sir Llewellyn Woodward, Franco
...wished to maintain Spanish independence, and therefore had no particular interest in helping to bring about an overwhelming German victory, still less a victory in which Italy would also put forward claims in the Mediterranean
Franco was later to make it known that...Gibraltar had to be captured with Spanish troops, which in itself clashed with German intentions
According to Ribbentrop, Franco also feared reprisals (e.g. losing the Canaries) from Britain if Spain helped Germany.
Thus, it is not hard to see why Hitler found Franco so stubborn about not letting German troops into Spain. Franco wanted an Axis victory, but not to the extent that it might compromise Spanish interests. Without Spanish cooperation, Operation Felix was pretty much a non-starter as the military costs for Germany would have been too high. Likewise, Operation Felix-Heinrich never happened due to reversals on the Eastern front.
One possible explanation is that the British bribed Franco to stay out of the war.
Churchill apparently convinced Spanish banker Juan March to act as a secret agent, organising payments of millions of dollars to Franco's generals in return for Franco agreeing not to side with Hitler
One reason not cited, was due to the overwhelming German victory in France--a win, so grand that no one had anticipated it! With the view that the German army was invincible. Therefore, they didn't need Spain, didn't require Gibraltar and the Soviet Union could be similarly easily defeated.