Only because they were having their ass handed to them on a plate. Toyota achieved literally nothing in their F1 stint, BMW did get some wins, but weren't competitive enough to justify the investment. Honda ditto, but left at the wrong time (the post-Honda Brawn team won the 2009 championship with the Honda designed car.)
Yes it has to make good financial and business sense if a company is going to be in any racing series. If you look one key reason BMW left.
Premium [brands] will increasingly be defined in terms of sustainability and environmental compatibility. This is an area in which we want to remain in the lead. In line with our Strategy Number ONE, we are continually reviewing all projects and initiatives to check them for future viability and sustainability. Our Formula One campaign is thus less a key promoter for us.
Norbert Reithofer
It was because they felt F1 wasn't relevant to their business and wasn't green enough. Okay, I'll agree to that but motor racing isn't about green, it never should be about green and being eco-friendly. It's racing FFS! If you come in it looking for butterflies and rainbows you're in the wrong sport.
And there are other racing series, which may be more road relevent. The Audi R18 e-tron has a Diesel hybrid drivetrainm with flywheel based energy storage. Very road relavent and innovative in the field.
And the FIA for F1 says storage is electric, Williams helped design the flywheel technology you mention and has quite a few patents around it however they can't use it in F1 and they're an F1 team. Again, teams can't innovate even on ERS design, it's mandated that it be this way because some bureaucrats thought it best.
It's not all about innovation. It's also about the grunt work of refining what you have. That's why Mercedes are dominating even the other identically powered cars. They've done the best job within the rules defined.
And there are lots of ways to innovate in chassis and aerodynamic design. The current crop of F1 cars have a very diverse array of front end designs.
And lets be honest, most F1 innovations don't translate to road cars anyway. The biggest influence of F1 and other motor racing has been in the engine management and fuel injection areas. Racing aerodynamics? Moot. Suspension design? Not applicable to most road cars. Sequential gearboxes? Came from bikes anyway. Tires? Irrelevent unless you only want your tires to last a week.
Agreed, they've done a great job but so have other teams but the rules like homologation for power units means that technology freezes for six years. Sure, gear ratios (twice a year) and fuel maps can be changed but if you did it right to begin with, that's a huge advantage but now that leaves everybody struggling because they can't innovate to compete. The only other area is Aero within a defined set of parameters, again, defined by the FIA and with cost reduction initiatives simulator time, wind tunnel time is all governed which means your racing to a budget, not producing the best thing you can. No team has infinite resources but it would be nice to see differences in the cars and different schemes, like maybe flywheel recovery in ERS but that's a pipe dream. What this leads to is conservative designs instead of leading designs for the sake of reliability vs ultimate performance. That makes it like a deranged pinewood derby.