The liner (or lining) can be a beautiful addition to a hat and even an extra selling point, a secret surprise inside hats like Bowlers or Fedoras, which might otherwise have a rather uniform appearance. Some liners are exquisitely made and embroidered.
One of the originally intended functions of the liner was to protect the felt of the hat from attack by the extremely oily products that men used to put on their hair. Many liners even included an extra transparent membrane, to protect the liner itself from such products.
Luckily for hats, those products are hardly used these days. If a modern hat still has a liner, it is more about branding and respect for tradition, than for any other reason. Indeed, many Akubra hats still have a transparent plastic film in the liner, protecting the company logo.