Simply put, the character was written horribly.
I personally don't think Dunst was miscast at all; she was cast while hot and popular off the "Teen" movies
Bring It On, Crazy/Beautiful, Dick, and
Drop Dead Gorgeous, and just finished co-hosting one of the most popular MTV movie awards.
So casting was on point.
In terms of how she looked in the movies, first movie is where her wardrobe worked best; however once Dunst got her personal stylists as MJ's stylist for the movies, I felt it was downgraded. Her hair was fine in 1 and perfect in 3; 2 felt like she looked like the stereotypical ginger where the lack of soul ginger jokes come from.
Where they really failed with MJ though, was the writing.
In SM1, she overall started well enough, no big issues really. Just your basic love interest for the hero. Starts off with Flash, they break up, goes to Harry, flirts with Peter, and flirts with Spidey, Harry breaks up with her and then she goes for Peter. Kind of skanky, but she's supposed to be a high school senior with home problems, so there's only the way up to go with her.
IN SM2, ugh, she was such a shrew. Dates JJJ's son, gets fussy with Peter over a play, connects again with Peter, all of a sudden engaged to JJJ's son, tries to creepily reenact the upside down kiss, still tries to see Peter on the side, gets kidnapped, see's Peter is Spidey and then leaves JJJ's son at the altar. Sorry but that is all kinds of sloppy, skanky, hot mess. Being overly hot/cold to Peter, treating JJJ's son like he's nothing and trying to make him kiss like a past flame, and then ditches him for no good reason. She had more than enough time to call off the wedding and could even blame her kidnapping if need be; she's a needy skank here and totally goes downhill in
In SM3, she now knows Peter's situation. Ok cool, but then, feeling ignored and jealous, she starts seeing Harry on the side the same way she saw Peter on the side when she was girlfriend to Harry in SM1 and JJJ's son in SM2. And not just once, but throughout the entire movie, and Harry is not just some guy either, it's Peter's best friend ever, and he's also her ex from high school that wasn't that long ago at the time. And Harry makes her break up with him! I know MJ is not genius level or anything, but no offense, if Spider-Man is your boyfriend, you can tell him what's wrong and work together on how to fix it, not all of a sudden just do what your ex told you to do. And for her to get mad that Peter went on a date after she broke up with him, after all the build up of the first two movies, it's just you can't sympathize for that character when she knowingly caused all of it. Then all Spidey saves her once more and their closest friend, that's so at the heart of their trio dies, they just brush it off literally after his funeral and have their happy ending. I will say, the upside down Spider-Man kiss was an ******* move on Peter's part, but MJ did the same thing as well in SM2, so that's karma. However, that's still not a good reason for MJ to leave the restaurant simply because Gwen happened to be there as well.
I know MJ is a free spirit, and she's had her fun as a bachelorette, but when she fully decided to be with Peter, she was devoted. She didn't want to be tied down to anyone, but Peter ended up making her want to be.
Raimi's movies got the entire essence of Mary Jane horribly wrong, and that's why no one likes her or her supposed romance with Peter much.