A quine is a program whose only output is its own source. The trick is always the same: keep the text of the program as data, and write code that prints that data twice, once as a quoted string and once as itself.
Here %r asks Python for the quoted representation of the string, so the output's first half comes out with its own quotes, and the %% becomes a single % so the second half comes out as code. Self-reproducing programs were studied by Paul Bratley and Jean Millo in 1972 in SNOBOL, Lisp, Fortran, and ALGOL 60; Hamish Dewar had written one in Atlas Autocode at Edinburgh in the 1960s. Douglas Hofstadter named them in Gödel, Escher, Bach in 1979 after the philosopher W. V. O. Quine, who studied sentences that talk about themselves. Nobody owns this particular one; it has been retyped by thousands of people who wanted to see the trick work. It is the smallest demonstration that a program can contain a description of itself, which is also the idea at the bottom of Gödel's proof and of the Lisp eval hanging three rooms back.