Margarine originally was a cheap butter substitute made by emulsifying beef fat with water or milk. Eventually animal fat was replaced by partially saturated vegetable fats, hardened by the process of hydrogenation, mainly for economic reasons. When saturated fats were linked with increased blood levels of cholesterol, margarine became a quasi-drug, at least until trans fats, byproducts of the hydrogenation process reared their ugly heads. “Interesterification” replaced hydrogenation with a view towards eliminating trans fats. In order to throw some light on how this happens, we have to dig into the chemistry of fats. Fats are "triglycerides" meaning that there are three fatty acids attached to a molecule of glycerol. An analogy would be a comb with three teeth, with the teeth being the fatty acids. The fatty acids are characterized by two features, the number of carbon atoms in the molecule and the number of double bonds between carbon atoms. Short chain fatty acids have less than six carbons, medium chain have six to twelve, and long chain fatty acids have more than twelve carbons. Saturated fats have no double bonds, monounsaturated have one, and polyunsaturated fats have two or more double bonds.
The physical properties of triglycerides are determined both by the carbon chain length and the degree of unsaturation. Shorter chains and more double bonds mean the fat is more likely to be a liquid. Olive oil, for example, is composed of 75% oleic acid (18 carbons and one double bond), 16% stearic acid (18 carbons, no double bonds) and 9% linoleic acid (18 carbons and two double bonds). Beef fat on the other hand is about 50% saturated fat, mostly palmitic acid (16 carbons) and stearic acid (18 carbons). Butter fat is similar. Saturated fats, particularly palmitic, tend to drive up cholesterol, whereas unsaturated ones don't. The idea behind margarine is to produce a product that has less saturated fat than butter but is not too liquidy to spread on bread. There are several ways to do this. The traditional way has been to eliminate double bonds in a vegetable oil by the addition of hydrogen. Of course elimination of all the double bonds would result in a hard fat similar to butter, so only some of the double bonds need to be eliminated. Partial hydrogenation can do this but it also introduces a problem. The hydrogenation process produces some trans fatty acids as a side product, and these of course have been implicated in heart disease.
How then can a liquid fat be turned into a soft solid without hydrogenation? The answer lies in a process known as “interesterification.” Basically this is the replacement of one or two of the unsaturated fatty acids in a triglyceride by a saturated fatty acid. Here is how the process works. A liquid fat that has mostly unsaturated fatty acids connected to its glycerol backbone is mixed with a solid fat such as glyceryl tristearate. The solid fat can be made by total hydrogenation of a vegetable oil such as soybean oil. Total hydrogenation gets rid of all the double bonds and does not produce any trans fats.
An enzyme, known as a lipase, isolated either from a fungal or bacterial source, is added to the mix of solid and liquid fats. This enzyme disconnects the fatty acids from glycerol producing a mix of glycerol and fatty acids. When the fatty acids reattach to glycerol they do so in a random fashion so that each glycerol molecule will have some unsaturated and some fatty acids attached to it. So some glycerols will have two saturated side chains and one unsaturated while others will have one saturated and two unsaturated. The end result is equivalent to a “partially hydrogenated” fat without having to go through the process of hydrogenation. Thus we have a spreadable product without any trans fats. It is also possible to make margarine just by physically blending a liquid oil and a solid fat such as palm oil but this has textural problems as the fats tend to separate. No matter how a margarine is made it has less saturated fat than butter. Of course it also has a whole lot less taste.