There are a few advantages of interpreted languages (compared to compiled languages)
- platform independence (you only need the interpreter for your platform, even though this is not true if e.g. your interpreted language is only a wrapper library around a library written in another programming language)
- dynamic typing (no need to specify the types of the variables)
- dynamic scoping (e.g. you can access variables in other scopes)
- automatic memory management (but there are compiled languages, like Java, that also have a garbage collector)
- Rapid prototyping (for various reasons, including dynamic typing), hence software can be written more quickly
Hence, the main advantages of an interpreted language compared to a compiled language are flexibility and dynamism. Given that AI is still an evolving field, these characteristics are widely appreciated.
There is also at least one disadvantage of interpreted languages (compared to compiled languages)
- Slower running times compared to compiled languages, which, once compiled, are quite fast, because they are often compiled to a code that is quickly executable by the machine or virtual machine
Python and R are widely used in data science and artificial intelligence because of the advantages above, which possibly contributed to the rapid growth of the communities around them and the development of software libraries.
However, note that the core of the most common machine learning libraries today, including TensorFlow and PyTorch, is written in a compiled language like C and C++. In the specific case of TensorFlow, Python is just a wrapper library. Consequently, under the hood, the code is not executed by the Python interpreter, but first compiled, which implies that, when you're using e.g. TensorFlow, your code will run (more or less) as fast as if you were using a compiled language like C. A similar argument can be made for libraries like NumPy, where Python is just a wrapper library.