Gordon Wenham addresses the problem of imprecations within the lament psalms by making the following three points (with some modification).
1. It is surely better to pray for God to punish the wicked than do it yourself.
2. These prayers for God to punish the wicked are expressions of hope in God’s justice.
3. Imprecations can be prayerful expressions of sensitivity for the suffering of fellow Christians.
Wenham, Gordon. The Psalter Reclaimed: Praying and Praising with the Psalms (Wheaton, IL: Crossway, 2013), 49.