It depends on the “what.” For most things, such as a new career, travel, or pursuing a new relationship, it is of course better to fail than to never try. After all, in case of failure, the lessons learned would be the foundations for possible future success. And, surely, there is no chance for success if one does not try. If you take the risk, and you do succeed, then celebrate! Enjoy that success; you’ve earned it! You’ve earned it for having the courage to do what other people say they want to, but wouldn’t.
However, for a few other things, it is better to never try than to fail. For example, it is better to never try suicide than to fail it. Or if one attempts it, then he/she better be damn sure to succeed. Here is a situation where failure is not an option. Failing a suicide attempt can be horrendous. One could end up with loss of vital physical facilities, or severe brain damage, or even be held by a locked-in syndrome — conscious, but unable to move, unable to communicate with the outside world, trapped in something akin to a different dimension, a kind of hell from which there is almost no escape.