The Israelites hadn't listened to God's instructions. The particular instruction was a warning not to do what the people around them did, and worship false gods.
I don't think the Israelites deliberately abandoned God, they probably just drifted away from him. God gave them this instruction to act like a boundary, something they knew they shouldn't cross. But it was no use to them if they'd forgotten it, or if they heard it but didn't measure themselves against it; it could only help them if they listened.
I think this passage makes me see why it is important not just to listen with our ears, but also to apply God's word to our lives.