Asalamu Alaikum
Both are Indo-Iranian languages, so naturally are quite similar. It likely would not have been difficult for Avestan speakers to learn Sanskrit, or vice versa.
They both came from a common, proto Indo-Iranian language which would have been spoken by the common ancestors shared by Iranians and Indo-Aryans.
Sanskrit itself has a very rich history, being the oldest Indo-European language with a substantial written documentation. It has a vast historical literature containing drama, religion, philosophy, etc.
The language was standardised by Panini, a grammarian from Pakistan (Charsadda to be precise).
Sanskrit has had a great influence on modern Indo-Aryan languages, with 50% of words from modern Indo-Aryan languages coming from Sanskrit. Many Indo-Aryan languages are still written in a similar script to Sanskrit too.