Why am I getting an error when trying to remove an inherited role?

Roles are hierarchical. For example, Role A inherits Role B, which in turn inherits Role C. When editing role A you can't remove Role C. However, you can remove Role B. To remove Role C from Role B, you must edit Role B.

In the UI, you see roles and the inherited-by roles. To see which roles are directly inherited by the role being edited, use the Inherited By filter.