While chest beating and face slapping are known ways of mourning by the Arabs, even predating Islam. The act of self flagellation using weapons (taṭbīr) for this purpose has no trace in Islamic history, the question then arises: What are the origins of this practice?
This will be answered by quoting and/or summarising some articles on the subject.
Among the people who support the ritual of self flagellation, you will often find them attempting to attribute this action to the Ahlulbayt (as) themselves. To do this often they will rely on unreliable sources which more-so resemble myths than actual historical reports.
An example is the report which was first transmitted by Al-Majlisī (d. 1110 AH) which suggests that Sayeda Zainab hit her head against a wooden pillar of a litter which led to blood coming out of her forehead, Shaykh Abbas Al-Musa has analysed this narration and showcased its extreme weakness. 
Another example that is brought forward is that of Imam Imām Zayn ul-ʿĀbidīn (as) when he allegedly hit his head on the wall and blood gushed forth from his head. This is found in the book ‘Dār al-Islām fīmā Yataʿalak Bilru’yah wal Manām’ (vol 2, pg 200) by al-Nūri al-Ṭabrasi (d. 1902 AD) – a book which is specific to dreams and visions. The story is without a chain, regarding a Christian man who saw visions in his dream. Upon hearing it, Imām Zayn ul-ʿĀbidīn (as) hit his head on the wall and blood gushed forth from his head due to the grief he had when hearing the dream. Naturally, this is a weak narration without any ancient primary source, nor a chain, nor even the name of the primary narrator.
The other narration which is often referred to in this discussion is that of the actions of Bani Asad. It is narrated that when they heard of the news of the martyrdom of Imām al-Ḥusayn (as) they struck their heads with swords and blood gushed from their heads. The narration is found without a chain in the book titled ‘Lam Takun Ridda’ (pg 272). Most pro-Taṭbīr scholars have not stated this narration is reliable and prefer the narration mentioned above regarding Sayeda Zainab (as) as an evidence.
It is also worth noting that besides their apparent extreme weakness in transmission, these reports are all also relatively late, something that appears for the first time with an author who died in 1902 AD and is attributed to an Imam who died in 95 AH is not a historical report even worth entertaining in this discussion.
Among the other scholars there is a difference of opinions as to the origins of Taṭbīr. The likes of Shaykh al-Muṭahhari took the opinion that it was from the practices of the Christians that eventually found its way to us through the Orthodox of Caucasus.  Dr. ʿAlī Sharīʿati added that the timeframe was around the Ṣafavid era.  As for Shaykh Ḥaydar Hobbollah, he adopted the opinion that the origins of Taṭbīr was during the Qajar dynasty.  The one responsible for introducing it was al-Fādhl al-Darabandi in a ritual for the revival of ʿĀshūrā’.  Aḥmed al-ʿĀmiri al-Nāṣiri adopted the opinion that the origins of Taṭbīr was from the Turks during the Ottoman dynasty under al-Ghāzi Murād Khān the first. This is from the affairs that is linked with the Inkishāri army. 
Shaykh Nāmi Farḥāt al-ʿĀmili comments after quoting these views: As for our opinion, we outright reject that Taṭbīr could have originated from the Inkishāri army since the Ottoman empire was the arch-enemy of the Safavid empire; and it goes against the intellect to suggest that the Safavid empire would blindly adopt the practices of their enemies. For the one who looks deeply into the books of history, he will see that the strongest opinion is that Taṭbīr originated – in the way that it is practiced today – from the Safavid dynasty in Iran, a practice which crept into theirs through Caucasus. 
Chest-beating and face-slapping, as has already been pointed out, were traditional ways of expressing personal grief and pain in Muslim societies. It is therefore not surprising that such acts were used to commemorate Imam Husayn’s martyrdom already during the Buyid period.  It is more difficult, however, to determine just exactly when and where knives, swords, and chains were first used by Shi’i mourners.
The earliest accounts of travelers go back to the first half of the seventeenth century. Comparing the pre-nineteenth century accounts of travelers to Iran, Henri Masse noted a fundamental difference in the nature of the Muharram processions. In the southern cities such as Isfahan and Shiraz, the travellers Della Valle, Thevenot, Tavernier, and Le Brun (whom Masse considered noteworthy for their precision) did not mention any shedding of blood. In contrast, in the frontier-like, Turkish-speaking regions of the Caucasus and Azarbayjan in northern Iran, the travelers Kakasch, Olearius, and Struys wrote that devotees struck their heads with swords. 
One of the earliest descriptions of the use of instruments to shed blood in commemoration of Husayn’s death is provided by the Ottoman traveller Evliya Chelebi who visited Tabriz in 1640 and attended the observances of the tenth of Muharram in that city. 
While flagellations as a form for reenacting the shedding of Husayn’s blood had existed in the Caucasus and Azarbayjan at least from the seventeenth century, the practice is not reported in the central and southern cities of Iran, nor among Imami Shi’is in the Arab world before the nineteenth century.
The flagellations were introduced into central and southern Iran, as well as into Iraq, only in the nineteenth century. Iraqi Shi’i oral history traces the appearance of flagellation in Najaf and Karbala to the nineteenth century. It is related that the practice was imported to these cities by Shi’i Turks, who came to Karbala and Najaf on pilgrimage from the Caucasus or Azarbayjan. 
There is no trace that this act of mourning by self flagellation has its roots in Islamic history, let alone that it was a Sunnah practiced by either the Prophet ﷺ, the Imams (as) or their companions. Rather we can see that it is clearly something foreign that has crept into the Shi’i school starting from the 17th century. It seems that the flagellations were introduced into Imami Shi’ism by extremist Shi’i groups, probably by the Qizilbash, whose doctrine and rituals were regarded by Imami Shi’i orthodoxy as exaggerated in reverence for the Imams.
This by itself is not sufficient to make something prohibited, to read more about it from a jurisprudential perspective and why it may still be impermissible, you may refer to the analysis by Shaykh Nāmi Farḥāt al-ʿĀmili. 
Perhaps in the future we will publish an article compiling the statements of the scholars regarding this matter.
والحمد لله رب العالمين وصلى الله على محمد وآله الطاهرين
An Attempt to Trace the Origin of the Rituals of ʿĀshūrāʾ, Yitzhak Nakash;
Taṭbīr (Self-Flagellation), Shaykh Nāmi Farḥāt al-ʿĀmili
|↑1||Read the translated article here: Did Sayeda Zainab practice bloodletting rituals?|
|↑2||A region located at the border of Europe and Asia, situated between the Black Sea and the Caspian Sea and occupied by Russia, Georgia, Azerbaijan, and Armenia. A less common definition includes also portions of north-western Iran and north-eastern Turkey. Today, the peoples of the northern and southern Caucasus tend to be either Sunni Muslims, Eastern Orthodox Christians and Armenian Christians. Twelver Shi’ism has many adherents in the south-eastern part of the region, in Azerbaijan which extends into Iran. (Wikipedia)|
Al-Jithib wal-Dafaʿ fi Shakhṣiyat al-Imām ʿAlī, Page 165
|↑3||Ruled Persia from 1501 AD to 1736 AD.|
Al-Tashayyuʿ al-ʿAlawi wa al-Tashayyuʿ al-Ṣafawi, Page 208.
|↑4||Ruled Persia from 1785 AD to 1925 AD.|
|↑5||Jadal wa Muwāqif fī al-ʿĀshir al-Ḥussainiyyah, Page 69.|
Also mentioned in Yitzhak Nakash, “An Attempt to Trace the Origin of the Rituals of ʿĀshūrāʾ”, pg 17
|↑6||Al-Taṭbīr – Its History and stories, Page 42.|
|↑7||Taṭbīr – (Self-Flagellation), pg 8|
Footnotes and comments by the translator of above document A. Ḥakīm have also been used throughout this article, you can find the translation of the article here: purifiedhousehold.com
|↑8||Ibn al-Athir, al-Kāmil fit-Tārīkh, vol 8, pg 549|
|↑9||Henri Masse, Persian Beliefs and Customs (New Haven, 1954), pg 128|
|↑10||Evliya Effendi, Narrative of Travels in Europe, Asia, and Africa in the Seventeenth Century, vol. 2 (New York, 1968), p. 138|
|↑11||Talib Ali al-Sharqi, al-Najaf al-ashraf: ‘adatuha wa-taqaliduha (Najaf, 1978), pg 220-23; Kazim al-Dujayli, “‘Ashura’ fi al-najaf wa-karbala’,” Lughat al-‘Arab, 2 (1913), pg 286-95|