Surely God is good to Israel (Psalm 73)
Psalm 73 is one of the Psalms of Asaph (see 50 and 74-83). It is numbered as 73 in Masoretic numbering while in Septuagint and Vulgate the numbering it is 72.
This psalm is raising a topic of prosperity of righteous and wicked people. For the author, as he observes, it seems like those who are disregarding God are doing much better than those who are faithful. Nevertheless, this perspective is changing when he thinks of the Temple. It reminds him of the eschatological future when the wicked will be destroyed and the righteous uplifted.
The topic, that the righteous is not always doing well even despite his righteousness, compared to the wicked, is also elaborated in the book of Job and Ecclesiastes. Each of these books in its own right and much closer detail.
This topic of good and evil, and justice and injustice also belongs to the collective human experience which can be, for example, found, in similar contours, in Plato's Republic (πολιτεία) or in Leibniz's Theodicy.