Sundar was pretty close to optimal. For internal consumption, it was an inspiring story of an engineer who rose through the ranks to the top, an affirmation of an engineering-centric culture. A foreign-born immigrant to boot.
And for external consumption: a polished, articulate, and presentable exec who can competently testify in front of the Congress or talk to politicians without giving off weird vibes, the way Zuckerberg and some others used to.
Sundar isn't a charismatic leader with a bold vision; he is a bureaucrat. But Google never really had a Jobs-style leader, and that might be fundamentally incompatible with the corporate culture over there. It owed a lot of its early success to great engineering, and the reason it maybe isn't working as well now is mostly a function of size. They used to be content with an innovative project that could bring in $50M... now it's not a success if there's no immediate path to $1B.
It also doesn't help that the company doesn't really have a clear product identity. Apple does consumer hardware and a bunch of services subservient to that. Google is... what? An advertising network? A vendor of office apps for businesses? An ISP? A grocery delivery company (they did that for a good while)? A social network? Oh, and that gaming thing with Stadia? And let's not mention their biotech and self-driving car ventures, now spun off but still paid for from the same coffers... it's admirable that they try so many things, but it makes it hard for them to stick to any long-term plan.
I don't think you can really pin that on Sundar - he didn't create this problem, although to be fair, he's also not fixing it.