What criteria are you using to judge the Harry Potter books? Don’t forget, they’re kids’ books, not adult works of fiction.
True, they don’t have the magic and depth of, say, The Wind in the Willows. Few books do. True, they don’t have the characterization, scope, or gravitas, of say, Phillip Pullman. But they’re great fun. They’re for KIDS, remember?
As a matter of taste, you may like them or not, but don’t fool yourself that they’re not well written. Some people don’t like fantasy. Period. You can explain to them all you like why they should, but my experience is that people usually either like it or they don’t. End of story. Much like rhubarb.
I don’t think Rowling is a great writer, but I still enjoy her books immensely. Rhubarb - not so much.