Some systems that are really made for this idea, where more failure eventually builds skill or ability, include GURPS and the older d6 West End Games version of Star Wars. Systems that grant experience points that can be used to directly augment skills are best for this.
When I was playing the West End Games version of Star Wars d6, I made up a rule that had to do with the "wild die." In that game, anytime the PC attempted an attack or action, in addition to the other dice rolled based on training/skill, there was a "wild die." If it turned up "6" then the DM narrated an extraordinary success. If it turned up "1", the DM imposed a complication. I let players make tally marks every time they got a "1" using a specific skill or attack. Then, when they had 3 tally marks, in any particular skill that they used, I'd allow them to bump up their skill one pip (that was a unit used in the game to grant a +1 to the die). It was really fun actually.
This system works with GURPS too because xp can be used to directly add to skills, talents, etc. Maybe each terrible failure adds XP.
For 5e, perhaps you can give XP for each "1" rolled. It would make rolling a one a bitter-sweet experience and might make it feel as if the PC is learning from failure. But, since D&D is a class based/level based advancement system, it is hard to allow for individual skills/proficiencies to grow outside the regular leveling mechanic.
Try the XP give away. Maybe 50 xp per level for each 1 rolled. Obviously the higher the bonus, the quicker PCs will advance in level. It may actually be fun. At least it will take the sting away from rolling so poorly.