High-redshift star-forming galaxies often have irregular morphologies with {\it giant clumps} containing up to 108−9 solar masses of gas and stars. The origin and evolution of giant clumps are debated both theoretically and observationally. In most cosmological simulations, high-redshift galaxies have regular spiral structures or short-lived clumps, in contradiction with many idealised high-redshift disc models. Here we test whether this discrepancy can be explained by the low gas fractions of galaxies in cosmological simulations. We present a series of simulations with varying gas fractions, from 25\%, typical of galaxies in most cosmological simulations, to 50\%, typical of observed galaxies at 1.5 < z < 3. We find that gas-poor models have short-lived clumps, that are unbound and mostly destroyed by galactic shear, even with weak stellar feedback. In contrast, gas-rich models form long-lived clumps even with boosted stellar feedback. This shows that the gas mass fraction is the primary physical parameter driving violent disc instabilities and the evolution of giant clumps on ∼108~yr timescales, with lower impact from the calibration of the stellar feedback. Many cosmological simulations of galaxy formation have relatively gas-poor galactic discs, which could explain why giant clumps are absent or short-lived in such models. Similar baryonic and dark matter mass distribution could produce clumpy galaxies with long-lived clumps at z∼2 if the gas fraction was in better agreement with observations.