You would do well to ask, “How could God’s law be a source of solace and comfort to the psalmist? ”
وَلكِنْ قَدْ يَتَسَاءَلُ ٱلْمَرْءُ :‏ « كَيْفَ أَمْكَنَ لِصَاحِبِ ٱلْمَزْمُورِ أَنْ يَسْتَمِدَّ ٱلتَّعْزِيَةَ وَٱلْمُؤَاسَاةَ مِنْ شَرِيعَةِ ٱللهِ ؟‏ » .‏