She was listening to music.

Literal

She [topic-は] music [object-を] was-listening.

聞いていた pairs the auxiliary ~ていた with the past tense to give a past progressive: 'was listening' (an action ongoing at some past time). Without ていた, 聞いた ('listened') would describe a single completed event. Note that 聞く covers both 'listen to' (deliberately) and 'hear' (perceive without effort) — context disambiguates, but with 音楽 as object it nearly always means deliberate listening.