Im very sorry about what happened to your friend,its indeed very sad to hear about such instances especially when a religious person is involved.
But we should always remember that Allah is our creator and there is no doubt that a creator(خالق) loves His creatures (مخلوق) and He doesnt want them to get hurt.
But sometimes in order to attain greater things and higher and esteemed status,we are compelled to undergo some hardships and tribulations in our life.
Allah wants to purify His makhlooq from all internal and external filth and impurifications just like the way gold is purified.Gold has to undergo through a long and hard process of burning in order to reach the level of purification.
Therefore when we face hardship and difficulties in our life its because Allah loves us and wants to purify us in order for us to attain a higher level of spirituality .
As our 6th imam says:
إنَّ عَظِيمَ الأَجْرِ لَمَعَ عَظِيمِ البَلاءِ. وَمَا أَحَبَّ اللهُ قَوْماً إلا ابْتَلاهُمْ.
The greatness of man’s reward goes with the greatness of suffering, and God did not love a people but that He subjected them to suffering.
We have numerous examples in history that those people who faced the most hardships in their life where the most dear to Allah swt.
Allah in sura baqarah aya no 216 says:
Surah Al-Baqara, Verse 216:
وَعَسَىٰ أَن تَكْرَهُوا شَيْئًا وَهُوَ خَيْرٌ لَّكُمْ وَعَسَىٰ أَن تُحِبُّوا شَيْئًا وَهُوَ شَرٌّ لَّكُمْ وَاللَّهُ يَعْلَمُ وَأَنتُمْ لَا تَعْلَمُونَ
and it may be that you dislike a thing while it is good for you, and it may be that you love a thing while it is evil for you, and Allah knows, while you do not know.
Regarding the second part of your question as to why Allah doesnt punish the wrong doers?
How can we say that Allah doesnt punish them.
What punishment can be more severe than being refrained from the mercy of Allah swt.
And the most important thing is that this world is not the place of accountability.its a place of action and the hereafter is the place of punishment and reward.
Its Allahs promise that He'll reward the righteous and punish the wrongdoers.
And there are times when Allah purposely gives time to the wrongdoers as the quran says:
﴿وَلَا يَحْسَبَنَّ الَّذِينَ كَفَرُوا أَنَّمَا نُمْلِي لَهُمْ خَيْرٌ لِأَنْفُسِهِمْ إِنَّمَا نُمْلِي لَهُمْ لِيَزْدَادُوا إِثْمًا وَلَهُمْ عَذَابٌ مُهِينٌ.﴾
And let not the unbelievers suppose that the respite We grant them is better for them; We grant them respite only that they may increase in sin; and there awaits them a humiliating chastisement. (3:178)