كَمْ عَاقِلٍ عَاقِلٍ أَعْيَتْ مَذَاهِبُهُ
How many wise people have exhausted all their means.
وَجَاهِلٍ جَاهِلٍ تَلْقَاهُ مَرْزُوقًا
Yet you find some ignorant people abundantly provided for.
A demonstrative may be used to point out an unexpected contrast: a capable person can fail while someone apparently less able prospers. The quoted lines illustrate the surprise that a pointing expression can accentuate.
Astonishment comes from the surprising state of affairs, not from the word “this” alone. Demonstration directs the listener toward the striking contrast.