Theme functions allow Drupal themes to alter module output before display. They provide a default style that theme builders can modify cleanly and easily. Template files generate output directly, while functions build a single variable and return it, making functions easier to use when more control structures are needed than plain HTML allows.