"A" denotes any object or person
"The" denotes a specific object or person
However, in THIS sentence, it is different and VERY nuanced.
Here, if the students "have the teacher", they have captured her somehow or obtained possession of her.
However, if someone said "The students have the teacher that won the nobel prize", then "the" would be performing its proper role in designating a specific teacher
If they "have a teacher" they have simply been assigned some random teacher.