‘On Time’ means exactly at that time. For example
The 5:30 local left the station on time.
The above sentence means that the train left at exactly 5:30. Similarly

I will come to pick you up at 6 pm. So be ready on time.
The function was organized well. Everything happened on time.
He left for his work on time but got late due to traffic.
The bus was late this morning. But usually it is on time.
Why are you never on time? You always keep everyone waiting.

‘In time’ means soon enough. It is used when something happens before time.
I reached the examination center in time and revised quickly before the exam.
Here ‘in time’ means before the start of the exam. Let’s take some more examples.

He got up in time and did exercise before going to work.
She does her household work in time to watch her favourite TV show.
The weather department issued the Hurricane warning in time. It saved many lives and property.
I got the scholarship in time. It helped me to continue my higher studies.