It wasn't a huge flop. That's a myth. It was the 27th highest grossing film of 1947 out of hundreds of films released by the major Hollywood studios that year. It wasn't a runaway success, either, but it wasn't a flop.
A lot of its latter-day success is attributed to the fact that, between 1974 and 1993, the film lost its copyright. It was due for renewal in 1974, but the owners of the film at that point missed the deadline. So during that 19 year period, it was often run on television stations without having to pay any fees since it was in the public domain. For example, here you can see that in Chicago during the holiday season in 1988, it was run no less than seven times on seven different stations--local channels WGN, WTTW, WYCC, WGBO, as well as cable networks AMC, TBS, and the Family Channel. (Chicago Tribune TV Week, Dec 4, 1988, p. 4)
This gave the movie a lot of exposure and it became enough of a holiday tradition that it was spoofed on Saturday Night Live in 1986, nearly 40 years after its original release. Similarly, the film National Lampoon's Christmas Vacation, released in 1989, features a scene where grandparents are sleeping through a broadcast of it in the afternoon during the holiday season--something of an anachronism now that it is only broadcast in primetime.
It regained copyright status after 1993 through a court case, because the short story it was based on, "The Greatest Gift", did have its copyright renewed properly, and as a derivative work, the copyright holders were entitled to payment whenever a broadcaster wanted to show it on television. Since the late 1990s, it has been shown exclusively on NBC.
Anyway, it was a well known film upon its release, and did OK at the box office but wasn't a smash hit. Its frequent television broadcasts in the 70s, 80s, and early 90s raised its profile considerably.