It is a very different way of thinking about programming, but immutable inputs remove a whole class of bugs that can happen.
It is analogous to global variables. We know they are bad, because any other piece of code can change them and break our code.
A variable having state is similar. When you think about what a function does or write tests... having the variable be able to have many unknown states increases the complexity.
In code we write everyday, a variable might be undefined, null, a valid phone number as a string, etc. But in immutable code, if your input comes from a function that returns either None or a valid phone number as a string and no other code can tweak this... then your code becomes much easier to think about and write tests for.
When it surprises you. It is easier to reason about code when you know that values will not change - an immutable value cannot change so you don't have to worry about passing it around, using it in asynchronous processes, changing it without persisting the change, etc.
It is analogous to global variables. We know they are bad, because any other piece of code can change them and break our code.
A variable having state is similar. When you think about what a function does or write tests... having the variable be able to have many unknown states increases the complexity.
In code we write everyday, a variable might be undefined, null, a valid phone number as a string, etc. But in immutable code, if your input comes from a function that returns either None or a valid phone number as a string and no other code can tweak this... then your code becomes much easier to think about and write tests for.