Does a heavier gauge stay in tune better?
Higher tension resists a light touch better. It does not fix the two things that actually cause most tuning drift.
There is a real mechanism behind this claim, which is why it persists: a higher-tension string is stiffer relative to the same finger or pick force, so it deflects less from ordinary playing — bends, vibrato, a hard strum — and a string that deflects less returns to pitch more precisely after each attack. Comparing this site's own reference sets for a 6-string electric in standard tuning, a Regular Light (10–46) set totals about 103.5 lbs across all six strings against a Super Light (9–42) set's roughly 85.1 lbs — an 18-lb difference in the guitar's total string pull, distributed across every string, not concentrated on one. That is a real stiffness difference a player can feel.
But "stays in tune" as most players experience it is dominated by two causes gauge does not touch. The first is a new string stretching in: any fresh string, heavy or light, creeps flat for its first hours of play as the winding settles and the material yields slightly at the tuning post, the nut and the bridge — stretching a new string by hand and retuning several times gets past this regardless of gauge. The second, and the more common ongoing cause once a string is broken in, is friction at the nut and the tuning-post wrap: a string that binds in the nut slot does not return to pitch smoothly after a bend or a whammy-bar dip, no matter how heavy it is, and a graphite or well-cut nut slot fixes far more tuning instability than a gauge change does.
So the honest answer is: yes, at the margins, a heavier gauge is a genuinely stiffer string and will drift a little less under identical technique — but it is a small effect next to a poorly cut nut, an old worn string, or a guitar that has not been stretched in. A player chasing tuning stability gets more from a proper stretch-in routine, a lubricated nut, and fresh strings than from jumping two gauges. Locking tuners and a well-cut nut solve the problem heavier gauges only partially help with, and they do it without changing how the guitar feels to bend or fret.
Where gauge genuinely does help stability in a way nothing else can substitute for: alternate and drop tunings that go BELOW a set's designed range, where a too-light string goes slack enough to rattle and lose pitch definition under any technique. That is a real, physics-driven case for sizing up — see the drop-D question on this site for the numbers.