The Verdict: Need More Info
Remote workers for employers abroad use the residence card for people living on their own resources, not a work permit. Whether remote work fits that card is not settled, so ask the local police foreigners' service.
That card requires an undertaking not to take up work in Morocco that needs Moroccan authorisation, and the law says nothing about work for a foreign employer. Morocco has no remote work or digital nomad visa.
Our Morocco retirement quiz covers the card. More than 183 days in Morocco in a year can make you tax resident there, so take tax advice before you go.