I have cited the following example sentences from Spanish Grammar Reference materials.
The Big Red Book of Spanish Verbs :
Preterit is used to tell what happened in the past. The event is completed in the past.
"Me levanté a las ocho. = I GOT UP at eight o’clock.
"Sonó el teléfono. = The phone RANG.
“Hice la cena y comí = I MADE dinner and ATE.”
"Ayer hablé con su madre. = I talked with his mother.
"Viví en España dos años. = I lived in Spain two years.
"¿Quién comió la fruta? = Who ate the fruit?
“¿Vendieron la casa? = Did they sell the house?” (Cf. Spanish Verbs & Essentials of Grammar)
Imperfect is used to tell what happened in the past with no specific beginning or end. The imperfect provides background information. The imperfect paints a description. You can think of the imperfect as talking about two or more different events or actions simultaneously happening in the same past.
“Eran las diez cuando llegaron los amigos. = IT WAS TEN O’CLOCK when our friends arrived.” [ it WAS TEN o’clock + WHEN friends ARRIVED]
- The imperfect describes what repeatedly happened in the (far) past. You can think of the imperfect as a way of describing habits during your childhood.
“Cuando vivíamos en Puerto Rico, íbamos mucho a la playa. = When WE LIVED in Puerto Rico WE USED TO GO to the beach a lot.”
- The imperfect describes the condition of what existed in the past.
“La casa era nueva y tenía habitaciones grandes y cómodas. = The house WAS new and HAD big, comfortable rooms.”
- The imperfect describes repeated actions of the past without having a specific time frame.
“Cuando yo era estudiante, iba a la biblioteca todos los días. = When I WAS a student, I WENT to the library every day.”
“Los fines de semana mis amigos y you nos veíamos en el café. = On the weekends my friends and I WOULD SEE EACH OTHER at the café.” [Cf. The Big Red Book of Spanish Verbs]
*The way I remember how to use the imperfect and the preterite (imparfait and passé composé in French): I imagine that the preterite talks about what happened an hour ago or yesterday while the imperfect talks about what happened two or more years ago (so long ago that I cannot pin a date or an exact hour to it…). When I use both the preterite and the imperfect to describe the past, the imperfect provides the description, the background, while the preterite points to the specific action that reached an end, or two simultaneous, “ongoing actions in the past”.
“Mientras yo leía el periódico, sonaba el teléfono. = While I was reading the newspaper, the phone was ringing.
[Neither the reading nor the ringing of the telephone are seen as events. Both express ongoing actions in the past.]”
“Yo leí el periódico y sonó el teléfono. = I read the newspaper and the phone rang.
[The use of the preterite for both verbs conveys the idea that the speaker sees both the reading and the ringing of the telephone as events.]” [Cf. The Big Red Book of Spanish Verbs.]"