It looks like this action needs the permission to draw over other apps since Android 10, but it's not marked as needing it.
Please give MacroDroid the permission to draw over other apps either through your settings app, or as a quick hack just add a launch app action and you will prompted to grant that permission (You don't need to actually add the action after this).
Unfortunately, it still doesn't work. I'm indeed using Android 10, so I checked for the permission to draw over other apps. I had given it already. It is also not asked for when adding a launch app action (I guess because the permission is already granted).
Unfortunately, this did not work. I revoked the permission and restarted my phone. After reboot, MacroDroid would ask me to grant the permission for another macro that I set, which includes an action to change screen orientation (invoked from a button press in the notification bar). This macro then continues to work without problem. The keyboard one still only works when MacroDroid is running in the foreground.