This depends entirely on how you are defining failure, as there are essentially two definitions, and it is crucial you understand the difference between the two.
- Do as many reps as possible as literally possible and nothing less.
- Do as many reps as possible to do while maintaining proper form.
If you are using the first definition then you are liable to run into massive trouble working out to failure. To begin with, your fail reps will be bad form which means at best you aren't working out your target muscles (think: using momentum during bicep curls) and at worst your form is setting you up for injury. This should quite obviously be avoided.
The second definition is where you want to focus, as you want to always maintain good form first and foremost throughout your entire set. If your form starts to give in the middle of that set, then your set is over and you need a rest or lower weight. I would also extend this definition to include effort necessary to safely rerack the bar (which can often be as much effort as a rep). This is the definition of failure that I use.
With higher weights there is always a safety concern with lifting just as you noted, but if you are taking the proper precautions there should be no worry about going to failure because you are using good form throughout.
As for the purpose of going to failure, there are really only two areas where it is useful:
- Bodyweight exercises are often unable to be supplemented with added weights, so you must rely on added reps to progressively overload the body to gain strength.
- When gauging your ability, doing reps to failure is a good measurement to use. For instance, I am doing three sets of 5 squats at 200 pounds. The first two sets I complete 5 reps easily. During the final set I go to failure and reach 15 reps. This is a cue that I am using a submaximal weight for my workout, and I may need to add a lot more weight.