What is wrong with this sentence and why? I would like to have a grammatical explanation. 我们八点上课，老师八点半才到了。
了 indicates the verb is 'completed'
我们八点上课，老师八点半才到。 would be a correct sentence
才 in 八点半才 indicated 'reaching 8:30' is a requirement for the action 'arrive' to apply, therefore, 到 is not a definitely completed action here. That is why the verb particle 了 that indicates the verb is 'completed' is not applicable when it is following 才 in a sentence.
我们八点上课，老师七点半 就到了 would also be a correct sentence, because 就 indicates 'already' therefore the verb particle 了 that indicates the verb is 'completed' is applicable
才 functions differently in different context
八点半(才) = (only when it is) 8:30 ; 八点半(才)到 = arrive (only when it is) 8:30
(才) 八点半 = it is (just) 8:30; (才)八点半就到 = It is (just) 8:30, he already arrived; (才)八点半就到(了) = It is (just) 8:30, he (had) arrived already
In Example 1. 'when it is 8:30' is a requirement for 'arrive' to happen. Therefore, you cannot add '了' to indicate the verb is completed
Verbs taking 才 do not take 了:
Note that verbs following 才 should not take 了.
✘ 她四十岁才结婚了 。
Expressing lateness with "cai", Chinese Grammar Wiki
I don't think it's wrong, since it gave correct meaning.
Consider the following sentence, "我们八点上课，老师(一般)七点五十才到". It means the teacher come at 7:50 for most time.
If omitting "了" the original sentence seems means that the teacher will always arrive at 8:30. However it obviously means that in a particular day, the teacher was late for class. "了" emphasizes that teacher had arrived but was late. When for emphasizing, the verb "到(arrive)" can be a bit stressed.
"了" has a second pronunciation of "liao", which is a more emphasizing tone.