The purpose of MRI is to get spatial information from the spins. It is true that chemical shifts give protons in different chemical environments different frequencies, however, the chemical shifts will not reflect any spatial information. For example, all of the water in the body has (roughly) the same chemical shift, whereas fat all has (roughly) a different chemical shift than water, but (roughly) the same chemical shift as all other fat in the body. If you left out the magnetic field gradients and the phase encode pulses, you would simply end up with a stand 1D proton NMR spectrum that had two broad peaks in it (one for water and the other for fat).
The gradient coils artificially spread out the precession frequencies much more than the chemical shifts do (in fact, the chemical shift differences are largely overwhelmed by the gradient coils). RF pulses with a bandwidth sufficient to excite the frequencies spread out by the gradient coils will have no problem with the relative small difference created by the chemical shifts, so all of the spins are still excited (Note: A 180º pulse would produce no signal. A 90º pulse would produce the maximum signal, but for signal-to-time reasons, MRI typically uses trains of small angle pulses, often as small as just a few degrees).
However, we can't ignore the chemical shifts entirely. After-all, we interpret differences in precession frequency as differences in position. This means that spins with different chemical shifts will produce images that show up at different positions in our final MRI image! Even worse than simple ghosting depending on the MRI protocol, you may get very bizarre artifacts due to the chemical shift differences... A great many clever protocols have been developed that exploit off-resonant effects to selectively excite only a narrow chemical shift bandwidth or to minimize the resulting artifacts, etc.
I would highly recommend getting a copy of Dwight Nishamura's book Principles of Magnetic Resonance Imaging. Very readable with lots of insight on what the spins are doing and what the pulse sequences are doing. One of the best introductions to MRI that I've read. He discusses this issue of chemical shift artifacts about half-way through the book if I remember correctly.