The basic function is to add customer appeal, I don't think they fulfill any really useful function unless maybe you have a baby Giraffe who likes car rides?
Dunno how they are fitted...maybe they assemble the rest of the car onto the sun roof? I'd guess the roof panel has the opening punched out before assembly...e.g it's built to order not modified.
Del
__________________
health warning: These posts may contain traces of nut.
I you live in a temperate climate then "Sunroofs" are a nice to have, certainly on a brisk spring morning.
My SAAB 900 Turbo (classic not GM) had one and I tended to use it a lot, instead of winding the windows down. I've owned several cars with them, it just adds to the pleasure of driving more than anything else.
Factory fitted sunroofs are fitted as part of the assembly of the turret. It's not really feasible to retro fit them, unless you do a "Cut and Shut" using a turret with one that has a sunroof onto your car.
Aftermarket Sunroofs are a better bet, not really a DIY job unless you are well skilled.
Basically sunroofs provide a convertable feel for you tintop sedan/hatch/wagon.
If I was buying a new car I'd be ticking the sunroof box, it does add resale value to the vehicle.
__________________
There are two reasons for a man to do a thing, One that sounds good, and the real one...