The Hadith referenced in the question prohibits Muslims from النِّيَاحَةُ عَلَى الْمَيِّتِ = lamentation on the dead
. We must however ask ourselves which people are considered dead in Islam, and whether or not Hussain-ibn-Ali is among them.
1- Is Hussain-ibn-Ali الْمَيِّتِ = dead
?
What does Allah say about the dead?
وَلَا تَحْسَبَنَّ الَّذِينَ قُتِلُوا فِي سَبِيلِ اللَّهِ أَمْوَاتًا بَلْ أَحْيَاءٌ عِنْدَ رَبِّهِمْ يُرْزَقُونَ - آل عمران 169
أَمْوَاتًا
is the plural form of الْمَيِّتِ
. So if someone is killed in the cause of Allah, considering him dead is not compatible with the Qur'an.
2- Was Hussain killed in the cause of Allah?
What does the prophet Muhammad (PBUH) say about him? Among many Hadith provided for Hussain-ibn-Ali in Sunni books, a few are listed below:
قَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ " الْحَسَنُ وَالْحُسَيْنُ سَيِّدَا شَبَابِ أَهْلِ الْجَنَّةِ وَأَبُوهُمَا خَيْرٌ مِنْهُمَا "
The Messenger of Allah said: "Hasan and Husain will be the leaders of the youth of Paradise, and their father is better than them." Sunan ibn Majah, Vol. 1, Book 1, Hadith 118
Another Hadith from prophet Muhammad (PBUH):
حَدَّثَنَا عَبْدُ اللهِ بْنُ صَالِحٍ، قَالَ: حَدَّثَنَا مُعَاوِيَةُ بْنُ صَالِحٍ، عَنْ رَاشِدِ بْنِ سَعْدٍ، عَنْ يَعْلَى بْنِ مُرَّةَ أَنَّهُ قَالَ: خَرَجْنَا مَعَ النَّبِيِّ صلى الله عليه وسلم، وَدُعِينَا إِلَى طَعَامٍ فَإِذَا حُسَيْنٌ يَلْعَبُ فِي الطَّرِيقِ، فَأَسْرَعَ النَّبِيُّ صلى الله عليه وسلم أَمَامَ الْقَوْمِ، ثُمَّ بَسَطَ يَدَيْهِ، فَجَعَلَ يَمُرُّ مَرَّةً هَا هُنَا وَمَرَّةً هَا هُنَا، يُضَاحِكُهُ حَتَّى أَخَذَهُ، فَجَعَلَ إِحْدَى يَدَيْهِ فِي ذَقْنِهِ وَالأُخْرَى فِي رَأْسِهِ، ثُمَّ اعْتَنَقَهُ فَقَبَّلَهُ، ثُمَّ قَالَ النَّبِيُّ صلى الله عليه وسلم: حُسَيْنٌ مِنِّي وَأَنَا مِنْهُ، أَحَبَّ اللَّهُ مَنْ أَحَبَّ الْحَسَنَ وَالْحُسَيْنَ، سَبِطَانِ مِنَ الأَسْبَاطِ.
Ya'la ibn Murra said, "We went out with the Prophet, may Allah bless him and grant him peace, and we were invited to eat. Husayn was playing in the road and the Prophet, may Allah bless him and grant him peace, raced the people and then spread out his arms. The boy began to run this way and that and the Prophet made him laugh until he caught hold of him. He put one of his hands under his chin and the other on his head and then embraced him. Then the Prophet, may Allah bless him and grant him peace, said, 'Husayn is from me and I am from Husayn. Allah loves anyone who loves al-Hasan and al-Husayn. They are two of my distinguished descendants.'" - Al-Adab Al-Mufrad 364 and also Sunan ibn Majah, Vol. 1, Book 1, Hadith 144
And what does Hussain himself say about the reason behind this battle?
اني لم اخرج اشرا ولا بطرا ولا مفسدا ولا ظالما وانما خرجت لطلب الاصلاح في امة جدي، اريد ان آمر بالمعروف وانهى عن المنكر
I did not come out seeking to do evil, nor seeking to have fun, nor seeking corruption nor oppression. Rather, I came out seeking reform in the nation of my Grandfather. I want to enjoin what is right and forbid what is wrong.[Testament of Hussain ibn Ali to Muhammad ibn Hanafiyah] 5
And also from himself:
الا ترون الى الحق لا يعمل به والى الباطل لا يتناهى عنه، ليرغب المؤمن في لقاء الله، فاني لا ارى الموت الا سعادة، والحياة مع الظالمين الا برما
3- Is there any permission to cry because Hussain?
Sahid al-Bukhari, Book 23, Hadith 62 says that the prophet Muhammad (PBUH) cried after his son Ibrahim-ibn-Muhammad passed away.
The case for Hussain-ibn-Ali is also outstanding, because he is killed in the cause of Allah (and so Quran says he is Alive with his Lord). There are several book chapters of Hadith that offsprings of prophet Muhammad (PBUH) cried for Hussain, like this chapter of Bihar al Anwar.
4- What is the benefit?
We may then ask ourselves: What is the benefit of lamenting and crying to the offspring of prophet Muhammad (PBUH)?
This is a good way to remember that Hussain sacrificed himself to prevent Yazid-ibn-Muawiya from changing the direction of Islam from the Sunnah of the prophet Muhammad (PBUH).
Hussain trained us not to live with obsession and not to be quiet upon the falsehood, even if it costs our life. And this may be a reason that prophet Muhammad (PBUH) said: Husayn is from me and I am from Husayn.
5- Are all types of mourning people do correct?
Definitely not. Most current Shi'a scholars do not permit people to show their sorrow by any means that severely injure the body, such as by hitting themselves on the head with a sword. Here is a fatwa by a Shi'a scholar, Sayed Ali Khamenei:
Any practice that causes bodily harm, or leads to defaming the faith, is Haram. Accordingly, the believers have to steer clear of it. There is no doubt that many of these practices besmirch the image of Ahlul Bayt's (a.s.) School of Thought which is the worst damage and loss.