Did they? Merc always had the best car since the switch to the V6. I mean imagine switching Vettel and Hamilton during that time when ‘Ferrari had the package’... I think Vettel would be winning the championship by a mile cos really Ferrari is kinda behind in F1 auto development for more than a decade now.
Ferrari never had the best car but more could have been done with the car they had. Imagine if Alonso had been kept instead of Vettel, I'm sure they would have more wins, maybe even a championship.
Certainly for a lot of the V6 period Mercedes have had the best car, and sometimes by a significant margin. However that hasn't been the case the whole time. Considering 2018 as an example, the Ferrari package was certainly equal to Mercedes and even ahead of them for some of the season. I'd agree with aesma on the Alonso angle. If Ferrari had Alonso instead of Vettel in 2018, it could well have been a Ferrari championship win.
If Hamilton has the best car, he wins. If Hamilton in a Merc is competing with Vettel in a just-as-good Ferrari, Hamilton wins. But put Alonso or maybe Verstappen in that just-as-good Ferrari, and whilst I'd still favour Hamilton, the question is certainly a lot more open.