The population of these places are largely of ethnic Spanish descent, although there are also large old minorities of people of Arabs/Berber extraction, Sephardic Jews, and Indians (from India).
Ceuta was conquered by the Visigoths already in 675, but c. 710 it became the foothold from where the Arab conquest of the Iberian Peninsula was launched.
I can be wrong, but as a Spanish citizen I would say that Spain retains these cities mostly because of their strategic value (cf. Gibraltar), and because there is also some psychological involvement (cf. Serbs and Kosovo).