Definitely depends on the game.
A controller with two analog sticks and two analog triggers has six analog axes of input. A keyboard and mouse has two. There are definitely games that can benefit from more analog axes -- think twin-stick shooters. You can use digital inputs for movement, but it's also less-precise.
On the other hand, a mouse can provide both rapid and precise movement, more-so than an analog stick. And a keyboard has a lot more keys, which is important for some games. And a keyboard is going to be a lot better for text input.
Controllers have output to players, in the form of rumble motors (and with some controllers on some platforms, more-exotic options). There's no widespread support for any kind of output from the mouse or keyboard. Use of rumble motors can add immersion.
While I've used a mouse as a flight input in Freespace 2, generally-speaking, I think that a controller's analog sticks are better for flight sims (though if you're playing an old-timey WW2 flight sim, probably getting a full-size stick with all the extra controls is worthwhile).
On the other hand, it's very hard for a controller to compete with the keyboard and mouse for first-person shooters. I've used one for some games that were designed for consoles and aren't very demanding in response and often have vehicles that are better-controlled with a controller -- I'm playing Starfield with a controller. But one is simply going to do much better with a keyboard and a mouse, if one practices with both. Playing an FPS with a controller feels like driving a truck.
Some games, like a number of strategy games, are going to be much-better played with a mouse. I have a hard time seeing Paradox's grand strategy games being played with a controller, even with a lot of work on the control scheme.
Ditto for RTSes. I've tried a few with controllers, like Supreme Commander, and it definitely benefits from a mouse.
Playing interactive fiction of the classic sort, where one types in commands, really, really needs a keyboard. There are ways you can mitigate a bit of the pain, and some point-and-click adventure games have tried to do this, provide a limited set of preset commands, but it's just not great.
Playing pretty much any game designed for a D-pad, I'd rather play on a controller. Yeah, you can get okay with a keyboard, but it just doesn't feel the same, not nearly as fluid.
And there are a few other input options that aren't seen much any more:
-
Full-size flightstick, maybe with throttle and pedals. Some had force feedback. I haven't seen many new releases; in the 1980s and 1990s, though, these were common for PCs.
-
Steering wheel