The sheep were grazing in the pasture.

Literal

Sheep [subject-が] pasture [at-で] grass [object-を] was-grazing.

はむ ('to graze / nibble') is a specialized verb usually applied to herbivores grazing on grass. Slightly archaic/literary in modern Japanese — everyday speech would just say 食べる ('eat'). Past ongoing ~ていた describes the scene as observed at the time. で marks the location of the grazing action.