"Harry Potter" is make-believe, and quite entertaining. "The Illiad" and "Lord of the Rings" are mythology, and also teach us while they entertain.
As a scholar, Tolkien lamented the destruction of whatever original mythology England might have had. So he decided to create one suitable for the country he loved so much. The books are only the tip of the iceberg, which includes a cosmology, history, and complete languages.
It's monumental effort over the course of his adult life, and a tribute to his scholarship and dedication. The story-behind-the-story holds valuable lessons for us, too.