This Psalm is a parable with the purpose of teaching lessons from the past. It was written to remind Israel of their spiritual failures, unbelief, and unfaithfulness and to contrast that with the amazing grace of God.
It lays out the importance of passing these lessons from generation to generation in an effort to avoid repeating past failures. Their forefathers had failed to keep God's covenant and refused to live by His instructions. They forgot all that God had done for them.
The Psalmist demonstrates this by recounting the events of the Exodus and wilderness wanderings. The people murmured while God mercifully performed miracles. God was faithful despite the numerous failings of His people. Yet they continued to sin.
God's people would turn to Him with their words to avoid punishment but their hearts were far from Him. Still, He had compassion on them and showed mercy.
This parable is meant to compare the incessant failures of man with the immense mercy of God. The failing of man is tragic but the grace of God is glorious. We have no excuse!