It is having time to think that makes me depressed.
In this sentence, what is the grammatical function of the word that?
The word that is a relative pronoun here.
The antecedent (what it refers back to) is it, the subject of the sentence. Because it is linked by a copula (is) to a subject complement, which is having time to think, the relative pronoun that indirectly refers to having time to think.
The relative pronoun is the subject of the relative clause that makes me depressed (the object is me; the object complement is depressed).
If one wanted to simplify this sentence without much loss of meaning, it could be rephrased like this:
Or, slightly more complex:
It is having time to think that makes me depressed is a Cleft sentence. It is derived from Having time to think makes me depressed by applying the It-Cleft rule, exactly the same way Bill kicked the can transforms into It was Bill that kicked the can via It-Cleft.
In an It-Clefted sentence, the usual designation of the that is as a relative pronoun, as noted by Cerberus. Or, if you go to a different syntactic church, it could be considered a complementizer for the relative clause (the relative pronoun having conveniently been deleted). Depends on various details of Cleft formation.
However, the sentence What makes me depressed is having time to think is a Pseudo-Cleft (or Wh-Cleft) sentence, also derived from Having time to think makes me depressed, but by a different Clefting rule. Pseudo-clefting could transform Bill kicked the can into What Bill kicked was the can.
The difference between the two types is exemplified here.