Why substitute? use stash, purchase local yarn, don’t want to use the original yarn, can’t buy original yarn, etc.
Several things to consider: yarn weight, construction, fiber, color.
If the pattern calls for worsted, for example, and you don’t want to do a lot of math regarding gauge, try to match yarn weight. This will be the easiest way to approximate the knitted fabric of the original piece when worked at the same gauge. Be aware, though, that even within standard yarn weights, the difference yarns can vary i.e. both may be called worsted, but one can be closer to DK and the other closer to Aran.
A single ply yarn behaves radically differently than a cabled yarn. A ribbon yarn looks and acts differently than a plied yarn. Worsted spun yarns result in different fabrics than woolen spun yarns. Compare, for example, a yarn like SHELTER to Cascade 220. You can get lovely cables out of both yarns, but the resulting garments will have different drape, overall weight, etc.
Wool, cotton, alpaca, silk – all are natural fibers but all have different characteristics which must be taken into account.
If you want your stitch details to show well, don’t pick a wildly variegated yarn with a lot of contrast.