Like Adjectives, relative clauses provide additional information about whatever they are paired up with.
|L'étoile qui a explosé est visible à l'oeil nu.
The star that exploded is visible to the naked eye..
The relative pronoun reflects the nature of the role that the modified noun (also know as the antecedent) plays within the relative clause. If the antecedent acts as the subject within the relative clause, qui is used.
|Le monastère qui est perché dans les montagnes est un endroit
The monastery that is in the mountains is a place of refuge.
Notice that the verb of the relative clause agrees with the antecedent (in this case 'le monastère') when it acts as the subject.
Ce chevalier qui attaque des moulins à vent est un peu
Le couteau qui a coupé la jambe de Jacques est limé.
Les dauphins qui ont sauvé ma vie reviennent me voir chaque
annèe dans la baie.
When the modified noun is the direct object of the relative clause, que is used. When this is the case the subject of the relative clause is within the relative clause.
Don't forget that elision takes place with que (before vowels or silent h it becomes qu').
Irrelevant in deciding between que and qui, is whether the modified noun is a person or non-person. (This is contrary to the interrogative pronoun qui which can only stand for persons.)