The Sims 2 is a great game for many reasons, including nostalgia... the game will always be a masterpiece. However, I'd have to say The Sims 4 is better mainly because it's newer and many features are more advanced. For example, I simply cannot go back to Sims 2's method of day/night or season cycles without cringing. The fact that returning home would bring you back to the time you originally left (regardless of the time it was just a moment ago) really bothers me... the same goes for advancing to the next season on another lot, but going back to realize it's back to the previous season again.
Also, Sims 4 has the best CAS and build/buy mode in ANY Sims game!
I'm definitely not saying Sims 2 is a bad game. It's not. Like I said, it's still a masterpiece! It was groundbreaking for its time and should always be praised as one of the best games of all time. It's just a bit dated. There's nothing wrong with that, though! Sims 2 was still the golden era of the franchise... and I don't think we'll ever see another iteration overtake it in that perspective (if that makes sense).
My Favorite Sims Games:
Sims 3
Sims 4
Sims 2
Sims 1
None of the games are terrible. They all have their pros and cons. In the end, I suppose it really depends on what we're talking about when determining which game is better/worse than another. It's actually kinda complicated to give a direct answer because of this reason. There are good and bad things about all the games.
Sims 3 is my favorite in the franchise, but I definitely still acknowledge its faults. Just like how Sims 1 is my least favorite, but I still acknowledge some good parts about it.