Spray foam is a chemical product created by two materials, isocyanate and polyol resin, which react when mixed with each other and expand up to 30-60 times its liquid volume after it is sprayed in place. This expansion makes it useful as a specialty packing material which forms to the shape of the product being packaged and produces a high thermal insulating value with virtually no air infiltration.
Spray foam insulation systems effectively seal walls, roofs, corners and other surfaces, creating a more comfortable household because it provides a barrier against drafts and associated pollen and dust. Long-term, properly installed spray foam won’t change its form or shape, meaning it will deliver the same benefits that it did years—or even decades—after being installed, while other insulation materials may settle and create future gaps in the insulation. 
Polyurethane is a closed-cell foam insulation material that initially contains a low-conductivity gas in its cells.[5] As a result of the high thermal resistance of the gas, spray polyurethane insulation typically has an initial R-value around R-3.4 to R-6.7 per inch.[5] In comparison, blown fiberglass typically has an R-Value of only R-3 to R-4 per inch.[6]

How Much Spray Foam Cost

If you don't have the patience to slowly fill the void with spray foam through holes drilled in one of the studs, you could (if you were an experienced carpenter) use a Sawzall to remove one of the studs and re-frame the corner as a two-stud corner. Then you could either insulate the void with a fiberglass batt or simply present the two-stud corner to the spray-foam contractor as an accessible corner. http://youtube.com/watch?v=ggLAUsiuI_o&app=desktop
Note: The practice of foam insulating the attic has raised eyebrows in the building industry because "standard" roofing techniques call for the attic to be ventilated; however, in a vented attic situation it will become approximately 130 degrees in the summer. There's no reason for an air-conditioning and vent-ductwork to have to work in that type of severe conditions. By applying Icynene right on the underside of the roof deck, the severe temperatures no longer exist in the attic. In short, the attic is now a "conditioned" space of the house that is just as comfortable as any other room in the home. This is called a "Compact Roof", which means you can frame right up against it. The one drawback of using expanded foam on the inside of the roof is that this will cause the temperature of the shingles to rise, but how much is not yet known. And how much damage a rise in temperatures could cause is debatable.

Roof Spray Foam Insulation