Why did David compose this Mizmor?
Malbim: It discusses the attributes of one who trusts in Hashem, and the difference between him and one who does not trust.
What do we learn from "l'David"?
Rashi: He rebukes Yisrael.
Radak: He speaks to anyone who hearkens to his Musar.
Why did he say "Al Tischar ba'Mere'im"?
Rashi: Do not compete with the success of Resha'im, to do like their deeds. This is like "v'Eich Tesacharah Es ha'Susim" (Yirmeyah 12:5), to run like they run.
Radak: Because [Mizmor 36] mentioned the thoughts and deeds of Resha'im, here it says not to be enticed when he sees their success, for it will not last; their end is bad. Do not mix with them.
Malbim: Do not heed their evil way and their success. If he does, he will (a) despise their way and confront them, or (b) envy their way and want to be like them.
Why did he say "Al Tekanei b'Osei Avlah"?
Rashi Do not envy [Radak - the serenity of] sinners, to do like them.