A function is a way to encapsulate a block of code. Say you have to do some computation multiple times. Instead of repeating the code that does the computation multiple times, you enclose that code in a function, and call the function every time you need to do the computation. A big advantage of this is that if you need to modify the computation code, you only need to do that in one place.
Another important use for functions is to decompose other long functions. Say you have a function where you first do A, then B, and then C. It is a good idea to separate the code that does A into a function, the code that does B into another function, and the code that does C into yet another function. Then you have your function just call those three functions. This makes it much easier to read and maintain you code.