Is there a right time to fail? Perhaps not. But there’s always a reason to fail.
Sometimes it’s to get you ready for something bigger.
Sometimes it’s to teach you a lesson.
Moses probably thought he had failed as the Prince by killing the Egyptian soldier (Exodus 2:12). Even though that “mistake” cost him his entitlements as a Prince, it got him ready for something bigger.
He never imagined that he’d be responsible for the deaths of more than one Egyptian soldier in future (Exodus 14:28), all for the same cause.
Failure sometimes comes on a small scale to teach us, so we know how to respond when the larger problem appears.
So perhaps the failure you experience now will save you some headache in future, making you smarter.