Macro software is not illegal, however using macro software to automate things in WoW is against ToS.
Basically you can use this software to map keyboard buttons on mouse buttons, for example, one mouse click = one keyboard press, that’s fine. But if you map one mouse click to two keyboard presses, that’s not fine.
Of course the above has nothing to do with in-game macroses. They were specifically created for allowed automatization, so feel free to use in-game macroses as you like.
Is it an in-game macro using WoW’s macro menu, or something from external software/hardware? Unfortunately people use the same word for both
You’ll never get banned for an in-game macro, because Blizzard made that system, it is theirs, they dictate how it works and what it can do. If they don’t want us able to do a particular thing, they’d remove it.
To make it work you’d press the key once for aimed, then again for rapid fire, then again for explosive. 3 actions, 3 clicks.
We are also free to macro abilities that are off GCD; a common one is pair a trinket with a cooldown so we only have to press 1 button, for example:
#showtooltip Dragonrage
/use 13
/cast Dragonrage
These are really normal macros and many many players use them, myself included.
OTOH you can get banned for mouse/keyboard/software external to WoW that can say “on click send a keypress, then 1.5 seconds later send another keypress, then 1.5 seconds later send another keypress”. 1 click, 3 actions, with timing - that is automation.