Yes and no – there are two types of optical cable connectors used in audio gear, so you might end up with a perfectly good optical cable, which won’t plug in – TOSLINK and miniToslink are the two you are most likely to come across on consumer gear, and many cables come with an adaptor on the end – if you know it’s standard TOSLINK at both ends, then the adaptors are useless flaps of plastic, if you need them, then they are essential.
In terms of quality, there are differences, but they don’t improve or detract from the picture – it’s much more about how durable they are, being semi-rigid means that the better ones are much less likely to snap, the cheaper ones are more likely to snap. If you are plugging in and forgetting it behind your hifi/TV, then it won’t matter, if you are plugging it in and out everyday, then a more rugged one is better.