It's historic. Holidaying in the south of France predates air travel. It was the preserve of (relatively) wealthy Brits who would take a boat across the channel then travel, perhaps by train, down to the Riviera. If they could afford it they'd take Le Train Bleu. As paid holidays and private cars became more of a thing for the middle classes from the mid twentieth century onwards, they also sought better weather, gastronomy, history and culture by taking holidays by car in France.
Relatively few travellers would venture over the Pyrenees and explore Spain and Portugal, which were rather poor and underdeveloped well into the second half of the twentieth century. Although the country has a rich history, it was less appealing to British travellers than Italy, where the legacy of Ancient Rome and classical civilization was a powerful draw.
Remember that Spain was controlled by the Francoist fascist regime until 1975, well within recent memory for my parents' generation and almost into my lifetime. This contributed to the lack of development and would hardly have made it a popular destination for the chattering middle classes. Influential media types and general leftie types certainly wouldn't want to chat about a trip there at dinner parties, and people from all sections of society who'd fought against fascism in the Second World War were probably not too keen either for some reason.
The tourist industry in Spain took off in the 1960s and 1970s. The country initially sold itself as an inexpensive destination for northern Europeans looking for warmer weather, a sun lounger by a pool, and inexpensive drinks. This was entirely understandable given the relatively low wages and low cost of living in the country, which was markedly less developed than other parts of Western Europe, but it is an inherently less upmarket offering.
Holidays in France are still more likely to involve driving France therefore lends itself to trips where you get off the beaten track and explore villages with little restaurants and old churches, go hiking or cycling. These are all more typically middle class/upmarket pursuits. Holidays in traditional resort areas of Spain very likely involve flying, and the place is much more geared up for providing the classic package holiday model: a coach transfer to a hotel with a pool, after which you're more likely to stay in the vicinity and enjoy a holiday that's centred around the sunshine, the beach and the pool. There's nothing wrong with any of that, but for whatever reason it's seen as more downmarket.