Well...it can affect both, but I was focusing on quality. Speed is a function of quality. :toothless
For a fixed idle air flow (or IAC duty cycle), advancing ignition timing will raise the speed because a) there is near-zero load on the engine, and b) the peak combustion pressure is higher. UP TO A POINT. When cylinder pressure becomes too high, it's working against the effort to create torque by pushing back the other way (before TDC). This is sometimes why bumping ignition timing can cause a loss in low-end torque (even though it may not FEEL like it).
The idle speed should always be regulated by the PCM, but whether it CAN is the issue, i.e. the PCM may 'learn' that a low idle causes stalling on the particular engine it's controlling, or it may be plenty comfy with its programmed idle that it's always trying to attain (it's a 'target' parameter in the program), or worst of all, it CANNOT control idle speed no matter what it does.
Many times, a fault in the IAC is to blame when the idle surges or it is too low. But like I've mentioned, fault(s) in other systems will be detrimental to idle quality (and speed as a consequence).