One of the very first few things that you come across when you learn a programming language or programming in general is static type language vs dynamic types language.
There is big difference, but if you never wrote code before or have little experince with programming then it will become difficult to understand the difference.
Let's quickly explain the difference between the two then see why both are exist.
Static types languages
If you declared a variable of type string, you can't reassign the same variable later on to a variable of type int the compiler will give you error before it even compile your program that you trying to use variable assigned string variable to a variable of int. this is what's called static typing you have to follow a string pattern in the language
Programming languages considered staic
C#, Java
Dynamic types languages
On the other hand in dynamic typing language you can declare variable of type string and then later on you can use this variable as int and the program will compile as normal.
Programming languages considered dynamic
Python, Javascript, PHP, Perl, Ruby