roles were initially defined by XHTML but were deprecated. However, they are now defined by HTML 5, see here: https://www.w3.org/WAI/PF/aria/roles#abstract_roles_header The role attribute is necessary to support Accessible Rich Internet Applications (WAI-ARIA) to define roles in XML-based languages, when the languages do not define their own role attribute.Although this is the reason the role attribute is published by the Protocols and Formats Working Group, the attribute has more general use cases as well.
Keep in mind that the attribute is necessery