Hello there! Thanks for the question. I think there are some people who are also interested in the difference between the two.
Shortening is a type of fat, saturated fat, that is solid at room temperature. Butter, margarine and lard also fall in this category. Most shortenings are made from vegetable oils but can be made with animal fat as well. Those shortenings made with vegetable oils are commonly made with partially or fully hydrogenated oils. What that means is that it makes these products more shelf-stable. By adding hydrogenated oils to the process can also add trans fat into the product. Trans fats have been associated with negative health outcomes.
Shortening is mostly used in cooking and baking.
Margarine is also a saturated fat and is solid at room temperature. Most margarines these days are made out of vegetable oils, so they have the polyunsaturated and monunsaturated fats, or good fats, that can lower your LDL when you are substituting saturated fat. However, not all margarines are created equal. Some margarines contain trans fats. If the margarine is more solid at room temperature, usually sold as sticks, they most likely have more trans fats. Margarine in tubs usually have less or no trans fat.
If you are considering using margarine, compare the products by reading the Nutrition Label. You want a margarine that has says no Trans Fat and has lower saturated fat.
Although margarines may seem healthier because they are made using vegetable oils, it is recommended by the American Heart Association to limit the intake of saturated fat to lower the risk of chronic illnesses, such as cardiovascular disease.
This page from a recent Ask A Dietitian question about vegetable oils and fat is also a good reference.