Wouldn't it be a pain if we had to write this code every single time we wanted to greet a user?

Well, functions make the process of building apps simpler, by making code reusable and easier to understand.