The first example breaks the program into two functions. It does the same thing as the second function. Both find the larger of two integers.
The difference is that if you want to do this operation again, you can just call the function again in the first example. In the second example, you have to write all the code again.
The most basic thing that functions are used for is to break programs into modular segments that can be reused and called by other parts of the program.
It also helps in debugging, and in making code easier to write and maintain.