Why do stabilised ylids lead to trans alkenes in the Wittig reaction?
TL;DR: With stabilised ylids, the trans oxaphosphetane is formed, under kinetic control. This is due to minimisation of dipole-dipole repulsions in the transition state for oxaphosphetane formation:



There is no equilibrium established between cis and trans oxaphosphetanes. The formation of the trans oxaphosphetane is irreversible, and its collapse leads to the formation of the (E)-alkene.



Long answer

Part 1: Oxaphosphetane reversibility?

The mechanism of the Wittig reaction has historically been controversial. Pioneering research, most notably by Edwin Vedejs and his group, has led to our current understanding of the mechanism as being a concerted [2+2] cycloaddition to form the oxaphosphetane directly. For more information, see: Which is the currently accepted mechanism of a Wittig reaction?



Within this framework, the formation of (Z)-alkenes from unstabilised ylids is understood to be because of a minimisation of steric repulsion in the cycloaddition transition state, as was proposed by Vedejs in 1988.1 For more information, see: Why does the unstabilised Wittig reaction selectively form cis alkenes?

For a long time, it was believed that oxaphosphetane formation from stabilised ylids was reversible. Consequently, the trans oxaphosphetane was preferentially formed (due to minimisation of steric repulsions), under thermodynamic control. The collapse of this then led to (E)-alkene formation.

However, this has been proven to be all but incorrect (and is sadly still propagated on widely used websites such as Wikipedia). A major problem with this theory was that oxaphosphetanes formed from stabilised ylids decompose so fast that they are not detectable via NMR spectroscopy.2 It is therefore implausible that the reversal of oxaphosphetane to starting materials can occur before forward reaction to form products.

The nail in the coffin was provided by Vedejs.2 If oxaphosphetane formation (from stabilised ylids) is indeed reversible, then it would mean that if the cis oxaphosphetane is synthesised, it should decompose to form the (E)-alkene via isomerisation to the trans oxaphosphetane. While the oxaphosphetanes themselves cannot be synthesised (they simply decompose to products), the corresponding betaines can be synthesised by deprotonation of β-hydroxyphosphonium salts (their conjugate acids).

The work by Vedejs proved that the syn betaine - which necessarily cyclises to form the cis oxaphosphetane - decomposed stereospecifically to the (Z)-alkene, hence disproving the idea of reversibility in the Wittig reaction. First, the relevant β-hydroxyphosphonium salts were synthesised:



Deprotonation of this formed a betaine, which would immediately cyclise to form a cis oxaphosphetane (this was well-established by then; see the question linked earlier on the mechanism).



If any of the (E)-alkene was formed, then it would mean that there was a mechanism by which either the betaines, or the oxaphosphetanes could interconvert. This would therefore not be conclusive evidence as to whether oxaphosphetane formation was reversible. However, if none of the (E)-alkene was formed, then it would necessarily mean that betaine and oxaphosphetane formation were both irreversible.

In their experiments, an E:Z ratio of > 98:2 was observed for all cases except for R = Ph. This indicated that in fact oxaphosphetane formation was not reversible, and that the stereoselectivity of the Wittig reaction cannot be based on a thermodynamic argument.

For R = Ph, 8% of the (E)-isomer of ethyl cinnamate was observed. Experiments with added 4-chlorobenzaldehyde ruled out the possibility of reversal to the ylid + carbonyl, as any ylid formed would preferentially react with the more electrophilic 4-chlorobenzaldehyde, leading to ethyl 4'-chlorocinnamate - but this was not seen. Furthermore, ethyl cinnamate was shown to be configurationally stable under the experimental conditions. It was finally found out that this occurred because, instead of deprotonating on oxygen, DBU deprotonated the carbon atom α to the ester, which led to loss of stereochemical integrity. This was further supported by deuterium labelling studies.



As a consequence of this, Vedejs concluded that oxaphosphetane formation was irreversible, and noted that for reactions with a stabilised ylid, the Hammond postulate implied a late transition state, which would "feel" stabilising or destabilising influences of the oxaphosphetane. Vedejs therefore proposed an almost-planar transition state, with the stereoselectivity rationalised by steric repulsions between the $\ce{CO2Me}$ and $\ce{R}$ substituents in the TS:





Part 2: Steric repulsions or dipole alignment?

In 2003, Varinder Aggarwal's research group managed to synthesise stabilised ylids with a $\ce{P(OMe)3}$ group instead of the usual $\ce{PPh3}$, and discovered that these ylids led to substantially lower (E)-selectivity.3 Vedejs' model could not be used to rationalise these observations:



To explain these, Aggarwal and Harvey put forth a different model, based on dipole-dipole interactions and supported by DFT studies:4



For the usual $\ce{PPh3}$ ylids, there is a strong dipole pointing from ylid carbon to ester group; in the trans TS, this dipole points opposite to the dipole of the C=O group in the carbonyl component. Hence, there is electrostatic attraction in, and stabilisation of, the trans TS. This explains the usual high (E)-selectivity.

However, for the new $\ce{P(OMe)3}$ ylids, the dipole moment of the ylid is much smaller. This is because the negative charge on the ylid carbon is delocalised into not only the ester group, but also the σ* orbital of the P–O bonds, which are energetically low-lying. This accounts for the lower (E)-selectivity of the phosphite-derived ylid.

As far as I know, this is the currently accepted model for why stabilised ylids lead to (E)-alkenes. Our mechanistic understanding of the Wittig reaction is very nicely summed up by Aggarwal and Harvey,5 in a grand computational study of all types of ylids. In it, they provided a full potential energy surface for the reaction of $\ce{Ph3P=CHCO2Me}$ with benzaldehyde (note that there is a typo in the ylid starting material in the diagram):



Ending with a quote from their paper, which perfectly summarises this answer:


  In the case of the triphenylphosphonium stabilized ylide, TS2 is very low in energy, showing that reversal cannot occur in these reactions, which is in agreement with experiment [...] E/Z selectivity is thereby determined solely by the relative energy of cis and trans TS1s. These energies, as well as the geometry of the respective TS1s, are strongly affected by a dipole-dipole interaction between the two reactants [...] The outcome for stabilized ylides is thus a high E selectivity.




References


Vedejs, E.; Marth, C.F. Mechanism of the Wittig reaction: the role of substituents at phosphorus. J. Am. Chem. Soc. 1988, 110 (12), 3948–3958. DOI: 10.1021/ja00220a037.
Vedejs, E.; Fleck, T. J. Kinetic (not equilibrium) factors are dominant in Wittig reactions of conjugated ylides. J. Am. Chem. Soc. 1989, 111 (15), 5861–5871. DOI: 10.1021/ja00197a055.
Aggarwal, V. K.; Fulton, J. R.; Sheldon, C. G.; de Vicente, J. Generation of Phosphoranes Derived from Phosphites. A New Class of Phosphorus Ylides Leading to High E Selectivity with Semi-stabilizing Groups in Wittig Olefinations. J. Am. Chem. Soc. 2003, 125 (20), 6034–6035. DOI: 10.1021/ja029573x.
Robiette, R.; Richardson, J.; Aggarwal, V. K.; Harvey, J. N. On the Origin of High E Selectivity in the Wittig Reaction of Stabilized Ylides: Importance of Dipole−Dipole Interactions. J. Am. Chem. Soc. 2005, 127 (39), 13468–13469. DOI: 10.1021/ja0539589.
Robiette, R.; Richardson, J.; Aggarwal, V. K.; Harvey, J. N. Reactivity and Selectivity in the Wittig Reaction: A Computational Study. J. Am. Chem. Soc. 2006, 128 (7), 2394–2409. DOI: 10.1021/ja056650q.