The reason for rebuilding of this mosque and others by the Almohads was that the originals, built by their rivals, the Almoravids, were considered heretical. The Almoravids were heretics in the eyes of the Almohads who built their mosques with the wrong qibla.
The qibla is the direction of prayer, the direction toward Mecca one faces when praying. More than that, it is the direction an animal is faced when slaughtered for sacrifice, the direction to avoid when spitting or relieving oneself, and the direction the deceased are aligned during burial.
The Almoravid mosques were designed with the qibla facing too far east. From Marrakesh and the surrounding Almohad Empire in North Africa and the Iberian Peninsula, Mecca was more to the south. Therefore, in order to worship properly in the mosque, some mosques needed to be completely rebuilt.
What was the state of Muslim science that would allow them to determine the proper qibla from different cities? Wouldn't it be nice to have a compass that would point toward Mecca? It would, and something like that was developed by a sultan who was also an astronomer. I'll tell you about him next time.