Why does it say "Hashem Tzadik Yivchan"?
Rashi: Because I am stricken and you pursue me, you say "Hashem Azavo" (71:11). This is not so! Hashem's Midah is to afflict and test Tzadikim, but not Resha'im. A flax dealer who knows that his flax is good - he beats on it. When it is not good, he diminishes crushing it, for it comes apart (Bereishis Rabah 32:3) 1 .
Radak: This is like "Ki Es Asher Ye'ehav Hashem Yochi'ach" (Mishlei 3:12). He brings afflictions on him and tests him in the eyes of the world, to show his virtue to people. His heart never falters due to afflictions. Also, [the afflictions] cleanse him from his sins.
Sha'arei Teshuvah (4:13): All afflictions of Resha'im are vengeance. Afflictions of testing come only on Tzadikim, who accept them amidst love and fix their actions more. The afflictions are for their benefit and to increase their reward.
Malbim: Hashem hides His Hashgachah, for via this He tests whether the Tzadik serves Him amidst love, without an external motive. Since the Rasha pursues him, and he does not falter from his virtue, this shows that he serves amidst love.
Lev Eliyahu (Shemos p.99): Hashem tests Tzadikim, even though sometimes they stumble in it, e.g. David with Bas Sheva, Bnei Yisrael at Mei Merivah
What is the consequence of Hashem hating his soul?
Rashi: He stores the payment for his sins for the long world [to come], and rains on (heavily punishes) him in Gehinom.
Radak: He does not rebuke him. He does not receive rebuke until his time comes, and Hashem eradicates him from the world.
Malbim: Even though hiding Hashgachah emboldens the heart of Resha'im to do evil, Hashem hates them, so He leaves them in their evil and does not punish them until their measure is full.