Why has Spain produced few famous scientists over the last centuries?

Spain has had a complex history that shaped the lack of a solid scientific environment over the past centuries.

First, Spain had a much harder Renaissance than France, England, or the Italian city-states. Spain spent a good portion of the Renaissance period engaged in a religious war to kick the Arabs out and expelling the Jews. Moorish Andalusia is where an important transfer of knowledge occurred. Everything associated with Moors and Ancient philosophy was considered heresy by the Inquisition and this probably made Spanish society more conservative. The Spanish inquisition truly dampened free inquiry and scientific exploration while France, England and the Italian city-states were creating the culture that nurtured most of the later famous scientists.

Then, the strongest resistance to progress and modernisation was probably expressed in the antagonism between the Francophiles and their opponents. Francophiles were accused of all sorts of religious heterodoxy. The 2nd May is a absurd public holiday in Madrid that celebrates the rebellion by the people of Madrid against the occupation by French troops. In reality, the 2nd May was a disaster day beacause of the following counter-revolution and reactionary policies. The people, blaming the policies of the Francophiles for causing the Napoleonic occupation by allying Spain too closely to France, at first welcomed Ferdinand VII. Under his rule, liberal schools and libraries were closed down, the engineering school was closed down, part of the press was suppressed and many editors and many writers were imprisoned. Even the liberal members of the Catholic church became victims of prosecution and the most scientifically educated group -the Jesuits- were expelled from Spain in mid XVIII.

And, last but no less significant, the Spanish civil war and the subsequent ideological conservatism of the dictatorship were a total tragedy for Spanish science. A whole generation of promising scientists was exiled.