It can be done by libraries, for example, which want their output to be valid in both HTML and XHTML.
Note that's it's not a syntax error in HTML - because HTML doesn't have syntax errors. The HTML5 spec tried to codify all the weird Postel's law quirks of existing HTML4 parsers, and in this case, tells you how to ignore the extra / if you're a parser. Nothing is a syntax error.
I didn't say it's a syntax error. I said it is not specified in the standard. You can put the slash there but it has no meaning, it does nothing, and browsers ignore it. If anything, it can cause problems: https://github.com/validator/validator/wiki/Markup-%C2%BB-Vo...
So it's best to not do it altogether. If one thinks they need to be compliant with both HTML and XHTML, I'd bet they have far more problems with the rest of their markup that would fail at such an effort.
Note that's it's not a syntax error in HTML - because HTML doesn't have syntax errors. The HTML5 spec tried to codify all the weird Postel's law quirks of existing HTML4 parsers, and in this case, tells you how to ignore the extra / if you're a parser. Nothing is a syntax error.