There is a misconception that the Sanskrit language is only used for chanting mantras in temples or at religious ceremonies. There are large chunks of Sanskrit literature which have nothing to do with religion. In fact, the Sanskrit language had produced great literature during the period from 600 AD to 1200 AD. Even though this excludes Kalidasa, who is believed to having written around the 5th century AD. Dandin wrote “Dashakumaracharita” (The narrative of ten young men). Subandhu wrote “Vasavadatta”, a long love story which is more intricate than Dandin’s work. “Panchatantra” (written before AD 600) is a collection of animal stories. These literary texts hold a very high position in world literature as they have been translated into many languages. These works enriched Sanskrit literature.
Not just literature. Great works of science have also been written in Sanskrit. Aryabhata contributed greatly to astronomy and mathematics. He illustrated the eccentric and epicyclic models of the movement of planets in the 6th century AD.
Brahmagupta’s “Brāhmasphutasiddhānta” and “Khandakhadyakaare” are great works of astronomy and mathematics. Great works on Ayurveda have been written in Sanskrit. Works like Ashtāngasangraha. It speaks in detail about eight important components of the Ayurveda.
The scriptures of Hinduism have been written in Sanskrit. However, the great contribution of literature and science makes it clear that the language is not the representative of Hinduism at all.
In fact, languages do not represent religion. Historically, Muslims have been learning new languages. According to newmuslims.com, the Prophet Muhammad himself suggested Zayd ibn Thabit, his own personal scribe to learn the Syriac language.
When Muslims went to different parts of the world, they learned the local languages there. They translated texts from different languages. Not just of Plato and Aristotle. They translated many great Greek books into the Persian language.
Some of the greatest achievements of the Muslim thought are in the Persian language. It has great personalities such as Saadi, Firdausi, Rumi and Hafez Shiraz. They all influenced world literature and made a remarkable impact on the pages of history.
Muslim rulers in medieval India had patronised Sanskrit. Abd-al-Qadir Badauni translated Ramayana and Mahabharata into Persian. Upanishads were also translated into Persian by Dara Shikoh, the son of Mughal emperor Shah Jahan. They were later translated into other European languages. In the 11th century, Al Beruni came to India and learnt Sanskrit. He wrote Kitab-ul-Hind in Arabic, which is part of our historiography now. Even during the Delhi Sultanate, many Sanskrit books on art, culture, religion, astronomy and medicine were translated into Arabic. Works like Zij-al-Sindhind are Arabic translations of Sanskrit texts. In the eighth century, works such as the “Sushruta Samhita”, a book on Ayurvedic medicine, was translated into Arabic.
Therefore, I think a Muslim can be open to the idea of learning Sanskrit. It’s alright for a Muslim to learn anything as long as it does contradict the fundamental teachings of Islam. And learning Sanskrit is not against Islam’s fundamental teachings.