As long as we are not talking about entry level stack setups, tone or quality is really arbitrary to each players ears. With that in mind, if you have both a great amp and cab setup, a different cab and guitar/pickups will make more of a difference in the tone than an amp will. The only huge difference an amp will make in the tone is the way the frequencies across the spectrum of your guitar are clipped, which changes the balance of harmonics of the distortion itself, but overall, not anything that is big in the sense of night and day, for the most part.
The biggest improvement that you can do if you have both a shit amp and a shit head is to get a better amp, as from my experience low quality amps are not musical with their distortion, then get a cab. But even we are talking about semi-decent amp, you would be better off getting a better cab first.