Q:

What caused the (relatively) recent popularity of set theory?

When I was growing up during the 1960s, "set builder notation" constituted a large part of what was then the "new math."

Question: When and why did "set theory" become popular in math education? Was it because of the earlier application of sets (and related topics such as topology) to real analysis?

(At heart, the question is what (if any) connection was there between the use of set theory in New Math at the elementary level, versus the expansion of real analysis to include set theory by professional math researchers?)

A:

Whenever "the new math" comes up, I must point out that there was no one "new math" curriculum and much of that post WWII exploration into math curriculum and pedagogy had different aims and philosophies (Davis, 2003). (This doesn't directly pertain to your question, but the actual use of new instructional methods and curricular content during this period was also not widespread or deeply penetrating into the educational system of the USA.)
So, in order to get a really good answer when talking about what was going on in the post WWII era, it may help to talk about a specific curriculum. Because, while some of the projects doing research at the time may have incorporated set theory, they may have done so for different reasons and there may not be one unifying philosophy. There possibly 30 or so projects that could be associated in some way with that era.
Angela Lynn Evans Walmsley (2003) sought to chronicle that time of reform and focus on the most prominent projects of the so-called "New Math movement," and she has this to say about the use of set theory:

Also, the language of sets and abstraction became part of the "new
  mathematics". Both set theory and abstract algebra became known
  synonymously with "new mathematics," but neither was a large part of
  the curriculum. (p. 75)

Later in that same book, the author makes reference to Morris Kline, an outspoken opponent of curriculum reforms who specifically attacked the requirement of using precise language and the inclusion of set theory.
My own conjecture is that the prominence of set theory in the minds of people when they consider "the new math" may be, in part, attributable to the critics who focused on set theory as either too abstract, or as substituting for the arithmetic that was the focus of a lot of traditional mathematics education approaches. Possibly, people saw it as something associated with the professional mathematicians who, in part, drove some of the ideas behind new (but not necessarily research-based) approaches to mathematics education. For whatever reason, its close association does appear to be disproportionate.
As for why it is there in the first place, the question would really need to be more specific. 
My general way of addressing the question (without a reference to back it up) would be that a structuralist approach to mathematics influenced the thinking of some mathematicians who wanted to see students build up their knowledge from axioms. Mathematicians might have been paying close attention to the writings of Bourbaki at the time, but to get reasons of set theory's inclusion in a curriculum, it would really be better to focus on a specific curriculum or set of related curricular materials.

Works Cited:
Davis, R. B. (2003). Changing school mathematics. In G. M. A. Stanic & J. Kilpatrick (Eds.), A history of school mathematics (Vol. 1, pp. 623–646). Reston, VA: National Council of Teachers of Mathematics.
Walmsley, A. L. E. (2003). A history of the “New Mathematics” movement and its relationship with current mathematical reform. University Press of America.

A:

My very incomplete understanding: I know from Henry Pollak (first-hand, but mentioned briefly here and in an article below) that one of the driving forces behind SMSG (with whom New Math is often associated) was Ed Begle. It should be noted that Begle's influence on mathematics education moving forward was also nontrivial: He served as advisor (along with Polya) to Jeremy Kilpatrick, who is perhaps one of the three most prominent names in mathematics education (the other two, in my opinion, being Schoenfeld and Ball; Uri Treisman is also pretty well known, and his mentor/advisor was the logician Leon Henkin, who was a student of Alonzo Church... but I digress).
Back to the main-story: You can see from Begle's wikipage that he served as the director of SMSG (School Mathematics Study Group) and that his background was in topology: Begle earned his doctorate under (algebraic) topologist Solomon Lefschetz, and he was also deeply influenced by the work of Raymond Wilder, as mentioned in this article (pdf) from The International Journal for the History of Mathematics Education. You can find my citation of Wilder's classic text on Set Theory in an earlier MESE response here. So, with minimal digging, we have already uncovered a fair amount of potential sources for set theoretical ideas to make their way into curricula associated with New Math.
Recap: "New Math" would have been influenced by, among other mathematicians, SMSG's director, Ed Begle, who was fond of the sort of notation you allude to when you ask about set theory. However, I'd like to return briefly to Pollak and another article in The International Journal for the History of Mathematics Education, available for free here (pdf). In particular, allow me to highlight the following two excerpts:

The "interviewee" above is Henry Pollak, and you can find in the article the foot-noted items. The real item of import is in the subsequent paragraph, and the point made that it was not so much about using set theory but rather about using "set ideas":

This conception of the ideas in "New Math" provides, perhaps, some support for JPBurke's conjecture about an over-focus on "set theory" in NM as overly abstract by its critics, whereas - at least in the case of Pollak, who worked with SMSG - the real motivation may have come from a more "applied" setting.
(This post really does not do the "full story" justice, but I thought it might shed a bit of light on the large question, and maybe encourage others to dig even further...) 

