Margarine was invented in France in the late 1800's as the result of a competition sponsored by their Emperor. There was a shortage of butter so a substitute was sought, especially one that was cheap and would keep for long periods of time. It was not created to be a health food.
Margarine caught on in the rest of the world after the rationed years of the World Wars. It is interesting to note that prior to 1920 Heart Disease was rarely heard of in America. By the mid 1950's it was the leading cause of death.
Margarine is made by refining various vegetables oils and blending them together with additives such as flavours, colours and vitamins, then emulsifying and pasturising the lot. All of this processing results in a product that will never turn rancid, contains traces of toxic metals, and that bugs and rodents won't even eat.
Butter on the other hand is made by letting the cream separate from milk, then churning it until it releases it's water (buttermilk). You can make it yourself at home by whipping real cream (not thickened cream!) till it forms lumps, drain the watery bit and what you have left is butter.
Of course I am not trying to suggest that butter is some super food, just that it is a completely natural whole food, which humans have eaten safely for many, many generations. It is easier to digest than some other forms of dairy, but heavier and more mucous forming than ghee, so not ideal for Kapha.
So if you really care about your health, always choose a natural food with has withstood the test of time.