We use a 24 micron selected sample containing more than 8,000 sources to study the evolution of star-forming galaxies in the redshift range from z=0 to z~3. We obtain photometric redshifts for most of the sources in our survey using a method based on empirically-built templates spanning from ultraviolet to mid-infrared wavelengths. The accuracy of these redshifts is better than 10% for 80% of the sample. The derived redshift distribution of the sources detected by our survey peaks at around z=0.6-1.0 (the location of the peak being affected by cosmic variance), and decays monotonically from z~1 to z~3. We have fitted infrared luminosity functions in several redshift bins in the range 0<z<~3. Our results constrain the density and/or luminosity evolution of infrared-bright star-forming galaxies. The typical infrared luminosity (L*) decreases by an order of magnitude from z~2 to the present. The cosmic star formation rate (SFR) density goes as (1+z)^{4.0pm0.2} from z=0 to z=0.8. From z=0.8 to z~1.2, the SFR density continues rising with a smaller slope. At 1.2<z<3, the cosmic SFR density remains roughly constant. The SFR density is dominated at low redshift (z<0.5) by galaxies which are not very luminous in the infrared (L_TIR<1.e11 L_sun, where L_TIR is the total infrared luminosity, integrated from 8 to 1000 micron). The contribution from luminous and ultraluminous infrared galaxies (L_TIR>1.e11 L_sun) to the total SFR density increases steadily from z~0 up to z~2.5, forming at least half of the newly-born stars by z~1.5. Ultraluminous infrared galaxies (L_TIR>1.e12 L_sun) play a rapidly increasing role for z>~1.3.