You multiply the cost of prevention by the risk of a crash and see if it exceeds the cost of a crash.
Some plane crashes can be prevented with a $0.30 warning light. Preventing those plane crashes is optimal.
Some plane crashes can only be prevented by permanently grounding all planes, because they'll be caused by a confluence of improbable events. Trying to mitigate every implausible circumstance that could potentially lead to a crash is not optimal, even when some of them proceed to actually happen.