Because she heavily plagiarized was inspired by the Worst Witch, which is one of the best selling children's books when she started writing her fanfiction Harry Potter. It's also not a coincidence that during that time period Lord of the Rings was also topping the charts...
Long story short, you know the lulz behind 50 Shades of Grey actually being a Twilight Fanfiction that got revamped into it's own thing? That's essentially what Harry Potter started as. A Worst Witch Fanfiction. Swap the genders. Toss in some Lord of the Rings stuff and D&D 2nd Edition stuff and presto. Hottest fucking seller to an entire country that never read the Worst Witch. The first three books were the best due to directly owing their stories other fantasies. The later books were weaker because at that point, JK actually had to write her own material rather than repurposes existing fantasy material.
Miss Cackle's Academy for Witches, a stone castle on top of a hill, surrounded by meandering forests and a pond , invisible to mere mundane humans becomes Hogwarts, a mysterious stone castle surrounded by meandering forests and a lake , invisible to mundane humans muggles. Home to the kind hearted and extremely powerful witch headmistress Miss Hubble, who's more like a mother to everyone or kind hearted and extremely powerful wizard Dumbledore who is more like a father to everyone.
Don't forget their evil, but not evil best friend and confident, Snape and Hardbroom.
Edit: GOOD GRIEF. THERE'S R34 OF SNAPE X HARDBOOM. CHEERIO MATES.
I'm not going to do every fucking character because once the teachers are done, the rest of the Harry potter cast is ripped straight from LOTR.
Remember kids. It's not plagiarism if you copy from MULTIPLE sources and tie them together. I respect it when it's done well and you can't pick it apart with ease. Actually, that's the only thing that pisses me off about J.K. She refuses to admit that she was inspired by THE HOTTEST KIDS BOOK OF THE DECADE when she was writing. At least have a crossover if you're never going to admit it.