Failure Teaches You More Than Success
Balance between order and chaos is important. Avoiding failure results in too much order. Although having a lot of order may seem desirable, it inevitably leads to stagnation and complacency. Everything tends towards entropy by default, and without effort to renew your order, you will not be prepared for the chaos that will emerge.
Failure is a part of chaos. Experiencing failure is good because it exposes you to the potential of chaos. It is an unknown that forces you to adapt and to improve in order to overcome the failure. Failure is the potential that allows you to improve. As antifragile beings, we require regular shocks through failure and chaos to thrive and grow.
Failure and making errors is an important part of neuroplasticity. It is what cues your brain to know that is is time to learn something new and to change. This is opposed to doing more of what you already know, which does not lead to neuroplasticity.
Even being in the flow state - which is an expression of what you already know - requires being on the edge and experiencing some challenge in the form or failures and mistakes. This is why deliberate practice is required to improve. It exposes you to what you are not good at (which inevitably leads to failure and making mistakes), without which we would default to what we already know, our current order.