There are two ways in which to answer this. Let me give you two types of answers. One from a human point of view, and another from a divine point of view.
From a human point of view, Hector died when he fought Achilles outside the walls of Troy. Hector knew that this fight was coming and so he stood outside the wall when Achilles was approaching. When Hector saw Achilles he was filled with fear. After running from Achilles, he finally mastered his fears and faced him. There was an exchange of spear throws to no avail. Hector at this point took out his sword to finish the fight, but he knew that he would lose. Achilles thrust a spear in his neck and Hector died.
From a divine point of view, it was destined that Hector would lose. Here is what Hector says:
"Alas! the gods have lured me on to my destruction. ... death is now indeed exceedingly near at hand and there is no way out of it- for so Zeus and his son Apollo the far-darter have willed it, though heretofore they have been ever ready to protect me. My doom has come upon me; let me not then die ingloriously and without a struggle, but let me first do some great thing that shall be told among men hereafter."
As you probably know, the gods are ubiquitous in Homer's Iliad.