Spain after reconquest of Granada.

If Spain had not discovered America and used their energy on the conquest of the newly discovered lands there, would they have continued their wars on the other side of the Strait of Gibraltar in order to conquer Morocco?
 
Probably. Many factors would have pushed to that.

1) There was a drive to do that based on Reconquista. Mauritania Tingitana was alloded to Hispania diocese in the late Roman Empire and was seen as an eventual target for Christian reconquest.

2) Takeover of continental trade roads for salt, spices, slaves and most of all, gold. All of these represented an huge thing (don't forget that a lot of monetary metal came from Africa) or at least its coastal entries.

3) Limitation of North African piracy (with Ottoman rise in Mediterranean Basin). More or less for the same reason that led Spain IOTL to conquer and hold several harbours in North Africa as Oran.

Now would a total conquest of Morocco would have been possible?
The IOTL Portuguese presence could indicate that the coastal control wouldn't be outside their grasp.

But it corresponded to a period of crisis for Morocco, and the rise of Saadi dynasty provoked a reflux (that wasn't complete as Ceuta and Meilla nowadays can proove). While an earlier coastal take over can take place, the cost of maintaining this presence in face of a most probable hostile population, with mountainous hinterland making resistance or at least independent clientelism more easy would be huge.

After a while, the question about investing on a full presence on the shores (without talking of the whole of Morroco) in face of the much more interesting Indian trade (as well the pretty much unavoidable discovery of Americas in the XVIth century) would put the whole thing in a more realistic light.

Maybe a more important Ottoman presence in the region, more hegemonic in North Africa could force Spain to hold more importantly its presence, but I don't see a takeover of the hinterland.
 
How large were the percentage of Muslims in Andalucia compared to in Morocco? After the reconquest Muslims and Jews were expelled, but I would assume there were quite a few Muslims also in Andalucia. Probably many of them moved to Morocco, increasing the percentage of Mulims there.
 
How large were the percentage of Muslims in Andalucia compared to in Morocco?
Morroco would be virtually at 90% Islamic, the rest being composed of local or Hispanic Jews.

Andalusia...It's hard to give even a guesstimated proportion, even without taking in account the problem of conversions and conversos (after the conversions of the early XVIth, can we consider moriscos and conversos as Muslims as a whole?).
These were quite important in Aragon (up to 1/3 in some regions) but much more limited in others, except Grenada.

After the reconquest Muslims and Jews were expelled, but I would assume there were quite a few Muslims also in Andalucia.
Actually, the expulision of Moriscos happened later, in the early XVIIth century. At this point they were more or less integrated (it seems that Castillan Moriscos were not only smaller, more assimilated to the overall population, while Valentian did kept their identity including Crypto-Islamism).

Probably many of them moved to Morocco, increasing the percentage of Mulims there.
Actually, only a few did go to Morroco. The country was too divided and troubled to really welcome or organise their arrivals, without mentioning the defiance if not hostility of North African population (remember that Moriscos were converted, even if crypto-Muslims; and that they were culturally really distinct and not integrated into the Berber or Arabo-Berber system) : IOTL many of them were killed in Barbary Coast (while the Sultan did tried to harbour them) that was their main arrival region.

It's not as all Moriscos were crypto-Muslims or particularly pro-Turks as well, a non negligible group settled in Mediterranean France (around 40 000 on 300/400 000 Moriscos) and others managing to stay in Spain basically undisturbed after the expulsions (it's harder to give an estimate, giving the official stance that there wasn't anymore of them. Maybe 10 000)

Depending how well Spain and Catholic powers fare against Protestantism (a failed Reformation would have certainly an impact on the "inner front" perception), Ottomans (Moriscos, critically in Aragon, being seen as a fifth column, not always wrongly), the date, the proportion, basically how expulsions would happen if they did would change greatly. By the XVII, however, I think discoveries of Americas would be done.

Back to the main question : they wouldn't change many things on the local capacity of resistance or unification. The IOTL exemple of Salé Republic, a corsair city-state barely if at all acknowledging Morrocean suzerainty is an exemple.
 
If Spain goes after Morocco they would expell the Jews

You had relativly few native Jews in coastal Morocco by then. Almoravids and Almohads reduced greatly their presence in spire of Merinid protection.
What was more important demographically was the weight of Hispanic Jews and these weren't exactly welcomed : robbed, raped, outright killed.

The lack of expulsions in Portuguese Morroco, and the actual interdiction to transport conversos to Christian North African holdings make me think about Christian Morroco being some sort of "Pale of Settlement" where Jewish population would have been held and periodically persecuted. (With a probable migration in Ottoman holdings as a consequence)
 
Top