I can actually see the appeal of Foligno from this data. His offensive capability is poor and has been for a while, no doubt about it. But his defensive stats are another story. In 2019-20 he was a better defensive forward than 98% of the league, according to this data. That's Bergeron territory, elite. Yes he dropped away defensively last year, but you could argue the plausible excuse that he had a mixed up season playing for two different teams who both had significant issues, and even then he was still in the 62nd percentile.
Sweeney runs a team that prides itself on its defensive structure and the ability of its forwards to play solid D. He looks at these numbers, and I reckon his eyes light up seeing that sort of defensive capability. The offense is by and by, he will probably have thought there are others who can provide that. He's also a known optimist, and he may well have considered that Nick would respond well to the Bruins' style and team environment. The rationale is probably if Foligno can be an excellent shut down forward while being a good mentor and leader and playing hard and physical on the ice, he'll be worth the $3.8m.
Of course most of this hasn't happened and it turns out that Foligno really is just burnt out, and it's a bad signing for sure, even though his defensive numbers this season are actually still respectable. The passivity is probably the most surprising thing. When Backes knew his body was failing, he tried to amp up the physical and bench leadership sides of his game even more. It had mixed results, but at least he tried. Whereas Foligno still seems to be just quietly going about trying to be a regular player and playing himself into form. Perhaps he simply hasn't come to acceptance yet that his best days, or even anything close to them, are over.