Sock yarn as a term refers to both a particular kind of yarn and a general category of yarn.
Loosely defined, sock yarn is, of course, any yarn that you use to knit socks. It can be lace-weight or worsted and made of just about any fiber under the sun.
Different kinds of socks, for different purposes, can be made with different kinds of yarn. I've knit super bulky knee socks that I wear to bed, worsted weight socks that are great for hiking boots as well as plenty of socks using the more traditional weight of sock yarn.
Most sock yarn, however, is yarn developed specifically for that purpose. It is usually lightweight (though it can be heavier) and knit on very small needles.
Sock yarn is often a blend of fibers that make the finished fabric more durable. While regular wool yarn can be used for a sock, many people prefer superwash wool for socks because it can be washed in a washing machine.
Other good choices for socks include wool blends and just about any kind of yarn with a bit of nylon added for durability.
Clara Parkes, whose spends a lot of time talking about sock yarn, says the best yarns for socks are elastic, because they need to stretch around a foot but then cling to the foot while wearing; resistant to abrasion, since socks rub on the foot, the shoe or the ground as they are worn, and that puts a lot of pressure on the fiber; and moisture management, because feet sweat and socks need to either absorb or wick away that moisture in order to feel (and smell) good.
And while cotton on its own would easily stretch out of shape, a cotton blend can be a great choice:
If you love the feel of cotton, consider a yarn that blends up to 50 percent cotton with wool. This is one of the most felicitous fiber blends possible, whether for socks or other garments, because each fiber perfectly complements the other, helping it to overcome its weaknesses without overpowering the blend.
Cotton, for instance, is great at wicking away moisture and actually gets stronger when wet, while adding wool brings softness, warmth and better ability to recover from stretching than you'd get with cotton alone.
If you're new to knitting socks, you'll probably want to start with yarns that are labeled as sock yarns because these tend to be more durable and easier to wash than similar weight yarns that aren't made for socks.
Of course, you can choose to use other yarns, but know that they might not stand up to wear on the foot as well as a traditional sock yarn might. You may end up with socks you don't ever want to wear with shoes, for instance, which is fine so long as you know that going in and aren't disappointed by the lack of hard-wearing.
If you want to try a yarn that's not made for socks in a sock pattern, knit up a swatch and carry it around for a while.
Rub it vigorously to simulate being in a shoe. If it starts to look worn right away, it's not the best choice for socks.