Qui functions as the subject in the sentence and is preceded by a noun or a pronoun. Qui replaces the subject. A simple way of knowing when to use qui is that it is followed by the verb directly e.g. c'est moi qui ai fait ça (It's me who did that)
Que functions as a complement to the indirect object (which sounds much more complicated than it is) it just means that que works as the direct object in the sentence e.g. c'est le cadeau que ma soeur m'a donné (it's the present that my sister gave me). The 'que' prevents you from having to start a new sentence again and saying the present again. You do not have a verb directly after using que.
Dont is the easiest one to distinguish as it is used to replace both que and qui when there would be a 'de' at the end of the sentence. We can't have a dangling de so we have to use dont where we need a relative pronoun instead of que or qui.
E.g. ici c'est le livre dont tu as besoin. Explanation: avoir besoin de quelquechose, you can't put ici c'est le livre que tu as besoin de because you can't have de at the end of the sentence 'dangling' so we replace it with the dont.