Tournaments were invented in the 5th century to improve knights’ skills and were a kind of sports competition. Medieval etiquette had a great impact on the nature of medieval wars, so there were tournaments instead of bloody battles.
Since the 14th century, tournaments started looking the way we know them now. They were conducted on special occasions like the return of a feudal lord from war or a crusade, wedding, birth of an heir, the signing of an important document, and so on. Only noblemen who could afford to buy special armor themselves were allowed to participate. Tournaments were traumatic and even fatal: in 1175, 17 knights died in Germany, and in 1240, more than 60 people died in Neuss. As you can see, knights didn’t fight for a lady’s handkerchief.