High-energy gamma-ray and neutrino production in star-forming galaxies across cosmic time: Difficulties in explaining the IceCube data