The building code requires a minimum amount of ventilation in the attic based on the amount of floor space. This ventilation needs to be split equally between intake vents in the soffits and exhaust vents in the roof or gables. The air circulation this design creates controls moisture, which can promote mold growth and rot the framing. It also prevents the attic from getting too hot in the summer, and therefore protects the shingles from overheating. Moreover, it keeps the attic cool in the winter. That's important, because when the attic space heats up, snow melts on the roof and forms ice dams.
An unfinished attic only requires insulation between the floor joists. It prevents heat exchange between the attic and the living space, and keeps temperatures in the house moderate. Homeowners can choose between faced and unfaced fiberglass batts or loose-fill insulation made from cellulose or fiberglass. There should be a moisture barrier between the insulation and the living space to protect against condensation, but there shouldn't be any barrier between the insulation and the attic, so the insulation can breathe. Proper insulation includes filling gaps around electrical fixtures and ventilation ducts with caulk or foam insulation.
When you're insulating around the perimeter of the attic floor, you must keep the insulation away from the soffit vents, or the attic won't have enough ventilation. An effective way to do this is to staple cardboard or foam baffles to the underside of the roof deck. They cover the vent opening, so you can push insulation right up the roof line and provide a pathway for air to migrate toward the exhaust vents. Baffles are also necessary when you want to insulate the attic so you can live in it.
When you convert an attic in a living space, you usually add vertical walls and use only a portion of the roof as a ceiling. Because you can insulate the walls, you only need to insulate that portion of the roof that serves as a ceiling in the room. To maintain proper ventilation, you need baffles under the roof insulation, and it should be placed in such a way as to allow circulation between the soffit and exhaust vents. Installing continuous soffit vents and a continuous ridge vent is one way to guarantee air flow between each pair of rafters.