Arabic originated from ancient Semitic language, and there have been ancient Arabic documents since the 6th century. Since the 7th century, with the expansion of the Islamic Empire, Arabs and Islam have been introduced to other countries.
Spanish originated from the vulgar Latin of ancient Rome, and Spain was occupied by the Roman Empire for more than 100 years, so the vulgar Latin spoken by Roman soldiers spread to Spain. Later, it was ruled by the Moors for hundreds of years, and it was mixed with a lot of Arabic. After a long period of evolution and integration, today's Spanish has been formed.