Spray foam insulation on Rafters

I performed an pre sale inspection yesterday and it was a century home. The house was in good shape but when I got to the attic I found this! My question is…
A) Has anybody ever encountered this?
B) Why would this be a good Idea or be done?

I would like to give the client direction on the resolve to this issue. The only thing I could think of would be Intumescent paint!?

This has been cover here lately .

Thanks Roy