Looking at the work more specifically than just the ubiquitous quality of entertainment, the appeal of Harry Potter is the the world-building. You get an idealized British culture reimagined with magic that contrasts perfect a sense of strangeness and wonderment with familiar features. We follow them through school, commerce, banks, transportation, sporting events, dances, bathrooms, cafeterias, etc. These ordinary settings and experiences are transformed through the magic and mythology to be strange, unsettling, and unique so that we witness what we normally take for granted with fresh eyes. It is both familiar and strange at the same time.
The same could be said for its themes of race, love, family, and friendship. The obvious theme that embodies the qualities I described above is the racial one (the conflict between mudbloods and pure bloods). From the reader's viewpoint there is nothing different about them as they both can perform magic so the conflict seems arbitrary. The binary of Muggles who cannot perform magic and those who can, which is a real difference, only further emphasizes the arbitrariness of this form of racism within the Wizarding Community. It allows children and readers to see how little difference there really is between people with so-called imagined differences. It uses it world-building to force us to confront old themes and conflicts in new ways and see them with fresh eyes.
Basically the books explore the deeper issues that affect teens and function much like any other literary book. This isn't to say it lacks elements to complain about
: no gay characters, a whitewashing and flattening of the characters of color (although in Rowling's defense she at least attempts to include characters of color), sometimes not featuring the women as prominently as they should in roles outside of domesticity (except for Hermione whose detractions critics greatly exaggerate). Still, I can think of lots of celebrated books that have these same problems so those certainly aren't grounds to dismiss the Harry Potter books.