It all depends on how an engine fails. A failure to provide thrust is survivable with more engines. But a vulnerability that causes a fuel line to go boom, taking out the whole rocket, is made more likely by having more engines.
IIRC, the engines in the Falcon 9 are pretty well separated from each other, such that even a catastrophic failure of one engine is survivable by the rest. Indeed, that seems to be what happened the one time an engine did fail (albeit on a very early version of the Falcon 9 with the "square" engine layout): https://www.youtube.com/watch?v=dvTIh96otDw
Engine didn't explode, it detected an anomaly and shut itself down. Here's spacex's statement concerning the event-
"Approximately one minute and 19 seconds into last night's launch, the Falcon 9 rocket detected an anomaly on one first stage engine. Initial data suggests that one of the rocket's nine Merlin engines, Engine 1, lost pressure suddenly and an engine shutdown command was issued. We know the engine did not explode, because we continued to receive data from it. Panels designed to relieve pressure within the engine bay were ejected to protect the stage and other engines."