There are many reasons for using functions.
The simplest reason is that if you do not use functions then you could end up with a very large block of code that is difficult to understand. Taking parts of the code out into a function can make the large block of code a lot smaller and thus easier to understand.
You also use a function if a piece of code occurs many times in your program/script. Put the code into a function and call the function rather than replicate the code. The use of function parameters/arguments allows the same code to work on different data.