The computer controls all that sht.
When you set the timing and lock down the distributor, check the timing again, the slightest movement when tightening it down will change the reading, lock it down, plug in the spout and start it up an the timing appears to change, the computer adjusts the timing many times during the running cycle and will appear to be all over the place.
Clearing codes: basically the computer gets to a point where it can't deal (adjust) per info it's given and says 'fck it', I can't deal with this and you get a crappy running engine, clearing the codes takes old info out of the equation, resetting the computer erases stored info and is needed when setting are changed like the tps (other things too).
This is all covered in the 'surging idle checklist'.