Pretty weird. You can’t sell a painting abroad? Wouldn’t that be good for Spain’s balance of payments? The payment is only like 100 years old.
I'm guessing that it's similar to our National Register of Historic Places. You might be the owner of a culturally significant property, but the government has seen fit to restrict some of what you can do with it based on a perceived importance of preserving it.
I have mixed feelings on the matter. Generally, I'm a strong believer in private property rights, but I think there is value in having the means in place to prevent say, the Mount Vernon's Ladies Association from selling the property to Chinese investors who were looking to develop high rise apartments on the grounds.