Max O'Rell, is widely credited with being the first English writer to frame the rule of "half plus seven." Here is his wording of the rule, in O'Rell, Her Royal Highness, Woman: And His Majesty—Cupid (1901) :
I heard the other day a very good piece of advice, which I should like to repeat here, as I endorse it thoroughly : A man should marry a woman half his age, plus seven. Try it at whatever age you like, and you will find it works very well, taking for granted all the while that, after all, a man as well as a woman is the age that he looks and feels.
The first thing to notice here is that O'Rell puts this rule forward as applying to an ideal difference in age between newlyweds—not a maximum age difference. The second and perhaps more glaring feature of the rule is that it applies to older men/younger women relationships, and not to the reverse. Evidently O'Rell would find the reverse application to be far from ideal.
In a Google Books search, matches for the rule of half plus seven go from zero in the period up to the year 1900 to five in 1901, two more in 1902, and two more in 1903. So the popularization of the rule evidently begins in 1901. However, one of the matches from 1901 suggests an earlier origin. The letters to the editor of Literature magazine (June 8, 1901) has two interesting posts on the question. First from the enterprising (and self-promoting) Mr. O'Rell, in a letter dated June 3, 1901:
Sir, Some months ago a few friends and myself discussed in my house what should be the proper age of a man and a woman who wish to enjoy matrimony for a long time. Many propositions were made. One man suggested that the age of the woman should be half the man's plus five. Then many other propositions were made. Mine, suggesting half the man's age plus seven was adopted. I have never read the works of the late Frederick Locker-Lampson, and, let it be said to my shame, never heard his name in my life.
I hate these coups de Jarnac that some English people (very few, I must say) delight in dealing in the back of successful book writers—in the name of the well-known British sense of Fair Play, I suppose.
Your obedient servant,
Immediately beneath that letter, the editor printed this one, written from Dublin on June 3:
Sir,—Your correspondent "Suum Cuique" is quite right. This is the passage from Mr. Frederick Locker's "Patchwork" (Smith Elder, 1879) to which he refers:—
I have a well-considered opinion as to the proper ages for man and wife. A wife should be half the age of her husband with seven years added. Thus, if the gentleman is twenty, his wife should be seventeen. If he is thirty-six, she should be twenty-five; and so on. No lady of the ripe age of fifty-seven has a right to indulge in the luxury of a spouse who (even though he may not be a magnificent ruin) is less than a century.
A search for the phrase "half the age of her husband with seven years added" confirms that Frederick Locker-Lampson, Patchwork (1879) does indeed contain the paragraph that A. L. cites.
Whether Mr. O'Rell independently devised the same rule (owing to its innate ruleworthiness, presumably) or whether he took it from Mr. Locker-Lampson without acknowledgment is a matter of conjecture. I can't think that in today's world either gentleman is likely to be admired for his insight so much as to be derided for his bald-faced presumption. But in any case, the rule of half plus seven most certainly appeared in print in 1879.
For a vivid illustration of the thinking of the times, consider Lady Poore, "Does Disparity in Marriage Tell Against Happiness?" in The Lady's Realm (November/December 1901):
Now, in the matter of age we may safely take the standard of perfection set up by Mr. O'Rell as sound and practical. He tells us that a wife should be "half her husband's age plus seven years," and any great deviation from this rule may be regarded as dangerous, or, at the very least, unadvisable. May and December do not combine well. Their points of view must differ too widely ; and May is rarely disposed to adopt December's experience at second-hand instead of buying it for herself.
Clearly, Lady Poore views O'Rell's rule as a restraint against even wider disparities in age between the (older) man and the (younger) woman. I suspect that the age-disparity-at-marriage question arose far more often at the turn of the twentieth century in instances of widowers seeking a too-young bride than in instances of middle-aged divorced men seeking a younger companion.