On time means you arrived right when you were supposed to. Not early or late. It can be used to show that you were not late when someone asks if you were late. Sometimes implying that you were going to be late. (I got here on time!)
Appointment at 8:AM
EX 1) I arrived on time for my appointment
EX 2) I was caught up by traffic but I still managed to managed to make it on time
EX 3) I arrived right on time.
In time is used usually when multiple activities are involved. This can also imply that you were going to be late. It can be used in many of the same ways as on time but the meaning changes slightly.
Ex 1) I arrived at the doctors in time to use the restroom
(If you replaced in time with on time in this sentence, it sounds like you made a appointment to use the bathroom at the doctors. Using in time implys that you had an appointment at the doctors but you had to use the bathroom. Luckily you made it there early so you can use the bathroom)
Ex 2) I made it in time for dinner.(Even though I had to finish my game)
Hope this helped, here is a link that can futher explain.
https://ell.stackexchange.com/questions/9623/difference-between-in-time-and-on-time