The purpose of a Java function, also known as a method, is to encapsulate a specific task or a set of statements into a single unit that can be executed whenever the function is called. This allows for code reusability, modularity, and improved readability.