While you can certainly knit socks out of almost any yarn, there are certain characteristics that make a yarn well-suited to this purpose:
Material: The first thing to look for in a sock yarn is of course what it's made of. If you're making socks that are going to get a lot of wear, it's generally a good idea to look for a yarn that has some sort of reinforcement material spun into the yarn. Nylon/polyamide is the most common of these, but there are several sock yarns now that are going all natural and using fibres such as flax, hemp, and even silk to help give extra toughness. You generally don't need to worry quite as much about softness in a sock yarn -- your feet are far less sensitive about such things than your hands, and yarns that have a bit of a wooly "bite" to them are usually quite durable and perfect for socks. If you're knitting for someone with sensitive feet or wool sensitivities, however, go with a softer choice just to be safe: just make sure it's an option that is well-reinforced with other materials.
Construction: The amount of twist that goes into a yarn helps add strength, so when looking for a good sock yarn, look for something that is fairly tightly plied. It's also generally a good idea to look for a smoother yarn -- something with a lot of bumps and nubbles in it will make a pretty shawl, but will make socks that are quite uncomfortable to walk on!
Gauge: Most yarn that is recommended for socks is fingering weight, although there are several good options made in heavier weights as well. If you are knitting from a pattern, it is important to make sure that you are using the correct gauge of yarn called for, or your socks won't fit and will either be far too dense, or far too open.
Quantity: If you're knitting a pair of socks with a fingering weight yarn, you'll generally want 100g of sock yarn. This should come out to between 375 and 425 meters of yarn. I tend to knit socks with about a 7" leg for people with large feet (women's size 10 and up), and almost always have a considerable amount of yarn left over, however, there are a few caveats to this rule of thumb.
First off, if you're knitting a more yarn-intensive pattern (such as cables), it's important to have a backup plan, since your socks are going to eat more yardage. This could mean having an extra skein as insurance, or planning to do cuff, heel or toes in a contrasting colour.
If you're worried about not having enough yarn to finish, use a kitchen scale! Weigh the sock yarn that remains just before you start the toe -- if you have a few grams more than half of the original yarn left, then it's probably a safe bet that you'll have enough to finish both socks without interruption. If, on the other hand, the remaining yarn is at, or less than half the original weight, it may be time to consider changing direction.
Colour & Patterning: This will depend a lot on what sort of sock you're making. If you're knitting something with a stitch pattern that you want to showcase, choose a sock yarn that has relatively few colour variations -- solids, heathers, tonals and long gradients are great for this -- rather than something with wild variegation, striping or patterning. If, on the other hand, you're looking to do a more basic sock, you have the option to go wild with sock yarn -- a plain pattern will let a complex yarn shine!
One thing I have noticed, and recommend a lot to newer sock knitters, is that stripes and patterns on socks are addictive. It's much easier to motivate yourself to knit "just to the end of the next stripe" when you're feeling like you're in the black-hole stage of knitting, so if it's your first pair of socks ever, be sure to choose something fun -- the dopamine rush of seeing how it knits out is one of the things that makes socks so fun!