The preterite tense indicates a single, completed action in the past. The imperfect indicates a continuous action in the past, a repeated action or a description.
Let's take the verb 'comer', to eat, and the Spanish writer, Cervantes.
Preterite: comí, comiste, comió, comimos, comisteis, comieron Imperfect: comía, comías, comía, comíamos, comíais, comían
Cervantes comió una manzana.Cervantes ate an apple. Single, completed action --> preterite.
Cervantes fue un escritor español. Le gustaban mucho las manzanas. Cervantes was a Spanish writer. He really liked apples. Cervantes is no longer alive, so we use 'ser' in the preterite. He liked apples in general --> imperfect.
Cervantes comía una manzana, cuando alguien llamó a la puerta. Cervantes was eating an apple, when somebody knocked on the door. Continuous action in the past (eating) --> imperfect. Single, completed action (knocking at the door) --> preterite.
Cervantes siempre comía manzanas, pero una vez decidió probar otra fruta. Comió una fresa y le gustó mucho. Cervantes always ate apples but one time he decided to try a different fruit. He ate a strawberry and really liked it. He always ate apples - repeated action --> imperfect. He decided once - completed action --> preterite. He ate a strawberry and liked it - single, completed action --> preterite.
Cervantes comió fresas durante tres días y no pudo parar.Cervantes ate strawberries for three days and could not stop.Action completed in a specific length of time --> preterite
Cervantes era un hombre inteligente y gracioso. Cervantes was an intelligent and funny man. Description --> imperfect.