There is plenty of opinion and theory on the topic. Volumes have been written.
Here's a starting guide...
Bottom line, give the engine what it likes.
On a dyno, most modern unmodified engines will reach mean best torque (MBT) before they begin detonating. At that point, adding more advance is useless (and more stressful), and power will begin to fall. Eventually detonation will set in. However, some engines are detonation limited and some timing value below that threshold will typically produce MBT. If you find more torque beyond detonation, its an indication that only a portion of the cylinders are detonating, but its still 'unsafe'. Give the engine what it likes.
At idle, good timing will generate good vacuum. Give it what it likes.
Fuel mixture effects the rate of burn, so it can have an influence on 'optimal' timing. Dyno will show MBT. Give it what it likes.
Lighter loads decrease the dynamic comp. ratio, causing a slower burn rate. More advance will prove 'better' with light loads. Fuel economy, response, and a dyno will help guide you with this. Give it what it likes.
Many engines will start anywhere between 0 and 20 degrees. Again, give it what it likes... you'll know.
You will usually find that there is a 'window' of MBT over several degrees of timing. Choose the lesser advance. In fact, slightly 'under' the window, with a slightly richer mixture often produces very similar MBT, with less stress.
Never run more advance than required to get you to MBT or knock threshold.
Tune. Tune. Tune... and don't forget to give it what it likes.