Margarine is a soft oil--it has a lot of water content, and becomes liquid at room temperature. If you bake cookies (especially really simple ones like sugar cookies) with margarine, they will be soft and mushy. If you use a lot of margarine, they will have a strong fake butter taste, like microwave popcorn.
Butter has less water, and melts at a higher temperature. It will make your cookies crisp, but also give them a cleaner taste. As for salted or unsalted - sugar cookies SHOULD be a bit salty, but I would personally use unsalted butter, and then add salt myself. That way you can control the taste.
You can use shortening, lard, margarine, or butter.
Butter gives the best flavor .. very rich.
Margarine is okay .. like a cross between butter and shortening.
Shortening is good for some types of cookies . you get a crisper cookie with shortening .. less melt-in-your-mouth.
Salted or unsalted .. use whatever the recipe calls for.
Some want just say "butter" in which case you are going to use the salted butter. But if they specific unsalted, then that is what you use. The cookies will still turn out okay, just better to use the ingredients that the recipe was designed to use.
Butter has a better flavor - and it's a natural product. Unsalted is preferred for cooking - as you know there is no added salt. You don't know the quantity in salted butter.