Knights, like castles, first appeared right around the year 1000 in western Europe (they were not found in England until after the 1066 Norman Conquest).
Basically a knight is someone who fights on horseback. The original, eleventh-century knights were not aristocrats, but rather henchmen on horseback, men who fought on behalf of the lords of the castle. (Click here for more on knights' horses.)
Fighting on horseback really only became a possibility with the development both of the stirrup, probably in the ninth century, and advances in iron-mining and metallurgy in the tenth century, to make horseshoes affordable. Without stirrups, one will slide off a horse's back far too easily. Without horseshoes, a horse's hooves will wear out unless it is kept strictly on grassy surfaces.
Hollywood now portrays all knights in plate armor. But that kind of armor only developed at the end of the Middle Ages and in the early modern period, when warfare was carried out with cannons and pikemen on foot, not cavalry charges, and the heavy plate armor protected people in jousts, mock battles that no longer had anything to do with real warfare.
Twelfth-century knights wore chain mail, generally a long tunic made out of metal rings. It was heavy and uncomfortable but would stop either a sword or a lance from penetrating. Their helmets covered the top and sides of the head and had a long nosepiece. Shields might be round or might be tall and kite-shaped, as in the image below.
These knights were carved on a church and were intended to represent the vices (if one looks closely one can see "…PERBIA" coming in from the left, the second half of the word superbia, meaning pride). The register above them shows images representing virtues.
Knights of course were proud; the church architects were right. And the service knights of the eleventh century desperately wanted to be like their aristocratic masters. Meanwhile, the noble lords of castles admired knights--their ability to fight on horseback, how cool they looked galloping across a field with a lance held high and cape whipping in the wind.
During the course of the twelfth century, nobles began to define themselves militarily, as knights, not just as people marked by great wealth, power, and noble birth. The knights, if they possibly could, married younger daughters of nobles, giving their children noble blood. By the thirteenth century, knights and nobles had essentially fused into one group.
(For more on chivalry and knighthood training, click here and here.)