In-universe, it was mentioned on several occasions that Popeye's desire for spinach (and the enormous strength it gives him) were linked to spinach's high levels of Vitamin A.
Out of universe, his love of spinach (and in particular fresh and later tinned spinach) were part of an extended marketing campaign by the US government to sell more spinach, particularly to impressionable young boys, hence why he didn't start eating spinach until several years after the comic was launched, during the depression-era food crisis and why he later switched to canned spinach during the war years.
Oh, and purely apropos of nothing, the idea that spinach was the inadvertant beneficiary of a misplaced decimal place was debunked a few years back. Myth busted.
The decimal point fallacy
Now, Popeye is unlikely to have known that because he was created
around 1929, featuring in his own cartoon in December 1930. A British
Medical Journal paper from 1981 claimed that the fallacy of spinach
being high in iron came about because the decimal point was placed in
the wrong spot in the original analysis back in the 19th century,
giving spinach an iron content ten times more than it was in reality.
Earlier this year, Dr Mike Sutton from Nottingham Trent University in
the UK, refutes the whole argument stating that there is no evidence
that a decimal point was ever placed in the wrong spot. He has even
written to author of the BMJ article and says the response from the
author provided no proof for the claim.
Popeye didn't eat spinach for iron