I have done a quick search and I have found in cases where 人気のある and 人気がある are used that に marks who something is popular with most of the time. Why is に used here and could we use some alternative to mark 生徒?
It's almost impossible to explain why when it comes to particle choice. I don't know why English speakers say "be popular with ～", but not "be popular to ～", but perhaps that's something you have to memorize rather than wondering why. It's the sixth (or eighth?) definition of this dictionary entry, if it helps. English is equally "illogical"; also see this.
So you should memorize ～は～に人気がある / ～は～に人気だ as a set phrase. You may see の used instead of が in a relative clause (that's a universal grammatical rule).
Using と will not make sense at all. Occasionally へ is used in a relative clause, but I would say using に is always the safest.
- 生徒に人気がある先生 a teacher who is popular with students
- 生徒へ人気がある先生 (less common)
- [x] 生徒と人気がある先生 (plain wrong)