This hadith is a weak Hadith from Sunan Abi Dawud, as classified by Al-Albani, according to sunnah.com.
Edit: As pointed by @goldPseudo and @American Muslim (in the comments), some sources marked this hadith as authentic. So, I did a little bit of research, and found the following sahih hadith:
Narrated Tariq ibn Suwayd or Suwayd ibn Tariq:
Wa'il said: Tariq ibn Suwayd or Suwayd ibn Tariq asked the Prophet (ﷺ) about wine, but he forbade it. He again asked him, but he forbade him. He said to him: Prophet of Allah, it is a medicine. The Prophet (ﷺ) said: No it is a disease.
Abu Dawud [29:19]
Since prophet Muhammad (pbuh) forbade alcohol even for medicinal purposes, it makes sense to say that all haram things are forbidden for medicinal purposes. As a result, the haith posted by OP is authentic since many sources marked it as authentic.