Knitting is hundreds of years old, but similar techniques are even older: sprang dates back to 1400 BCE at least, and nålebinding as far as 6500 BCE.
Textile history is a tricky discipline; fabric tends to disintegrate a lot quicker than stone or even wood. So while we have some early evidence, it’s almost certainly not the start of the history.
Sprang is a method of making fabric that’s like knitting, but involves only warp threads twisted together like a game of cat’s cradle. You can make something that looks a lot like knitting, although you need a loom to make it. Some sprang was dug out of a bog in Denmark and dated to 1400 BCE.
Nålebinding is even older. It sounds a little like crochet, using only one needle, and an example has been found in a cave in Israel that has been dated to 6500 BCE. In contrast, the oldest extant knitting is only about 900 years old.
Vikings loved nålebinding, and the Egyptians too. The image above shows some Egyptian socks from about 300-500 CE. They look comfy.