When Kacey Musgraves was 9 years old, she stood in front of a shaky camcorder and wondered, “Why are there so many songs about rainbows?”

These days Musgraves is the widely acclaimed country star whose most recent LP, 2018’s “Golden Hour,” won the Grammy Award for album of the year. But back in 1997, she was just a kid from small-town Texas mustering the courage to perform one of her favorite songs for her voice teacher.

“Mom, if I forget the words, will you help me?” Musgraves asks quietly in a video of the recital posted on her YouTube page. Then, as the camera settles on the long-haired girl wearing jeans and a baggy T-shirt, she starts into “Rainbow Connection,” the plaintive ballad famously introduced by Kermit the Frog in “The Muppet Movie” and subsequently interpreted by everyone from the Carpenters to Weezer to Musgraves’ pal Willie Nelson.

Decades later, Musgraves, now 31, has followed in Kermit’s footsteps — and evoked his question concerning songs about rainbows — with a gently uplifting tune of her own that has touched a broad array of listeners thanks to its soothing image of color and light.

Originally positioned as the hymnlike closer on “Golden Hour,” Musgraves’ piano-and-vocal “Rainbow,” in which she assures the listener that “there’s always been a rainbow hanging over your head,” has become an anthem of encouragement amid the COVID-19 pandemic.

Social media is filled with videos of folks covering the song (including celebrities such as Kate Hudson and Ben Platt). It soundtracks a Target commercial saluting the retail chain’s workers. And last month Musgraves performed it on Global Citizen’s “One World: Together at Home”“ special, where she was accompanied by photos of rainbows drawn in cheerful sidewalk chalk and hung on homemade banners in windows around the globe — the latest application of a durable emblem seen broadly in fashion, memes and emoji.

“It’s almost like a higher power knew what was coming and that the world would need this at some point,” said Shane McAnally, the experienced Nashville, Tenn., songwriter who wrote “Rainbow” with Musgraves and Natalie Hemby. “It definitely feels like somebody else was guiding the pen.”

However divine its inspiration, all the exposure for the song — streamed more than 100 million times, according to Nielsen Music — has revealed the expertly rendered makings of a modern standard; it’s sweet but sturdy, openly emotional without being maudlin. And as with Leonard Cohen’s “Hallelujah” or Simon and Garfunkel’s “Bridge Over Troubled Water” — or “Rainbow Connection,” which Musgraves performed with Nelson at last year’s CMA Awards — it’s easy to imagine the long life that “Rainbow” has before it on awards shows and singing competitions and in slow-moving montages of brave first responders and essential workers.

Against a churchy chord progression that seems heavy and weightless at the same time, Musgraves addresses someone who’s finding it “hard to breathe when all you know is/ the struggle of staying above the rising water line.” (Heed the deft internal rhyme of “struggle of” and “staying above.”) Then she pauses ever so slightly before pushing her voice upward, just where you need it to go, to declare that “the sky is finally open, the rain and wind stopped blowin’.”

The effect is like she’s thrown out a lifeline.

“Music finds its way into so many cracks and crevices in pop culture — it can give people something to latch onto,” Musgraves told me in 2018. “There are good things out there, even though that’s not what’s on the frontal lobe of everyone’s mind these days.

“But if you manifest something really positive in your songs, it almost creates a reality.”

“Rainbow,” like most standards, didn’t start out where it’s ended up. Motivated by her horoscope, Musgraves (who declined to comment for this article) turned up at a writing session approximately seven years ago determined to create a song with that title, McAnally recalled. Her optimistic tone surprised him, he said, “because at that point she’d never cut anything with this kind of self-help vibe.”

With songs like “Merry Go ’Round” — about how “Mama’s hooked on Mary Kay/ Brother’s hooked on mary jane/ And Daddy’s hooked on Mary two doors down” — Musgraves’ 2013 debut, “Same Trailer Different Park,” had established her reputation as a skeptical chronicler of small-town life.

“A lot of it was funny in a less-than-humorous way,” said Mike Dungan, chairman and chief executive of Universal Music Group Nashville, which includes Musgraves’ label, MCA.

Yet the grassroots success of “Follow Your Arrow,” a fan favorite from the debut that nonchalantly embraced same-sex romance, “showed Kacey how gratifying it could be to write something that gave people hope,” said McAnally, one of the few openly gay men in mainstream country music. So he, Musgraves and Hemby set out to pursue the singer’s idea, thinking in part about the symbolism of the LGBTQ community with which Musgraves has long allied herself.

Even so, using the term “rainbow” presented certain writerly challenges, not the least of which was the forbiddingly high bar set by “Rainbow Connection” and especially “Over the Rainbow,” the Yip Harburg/Harold Arlen monument to hope from 1939’s “The Wizard of Oz” that launched Judy Garland toward gay-icon status and which McAnally called “just about the best song ever written.”

Paul Williams, the veteran songwriter who co-wrote “Rainbow Connection” (along with other pop classics such as Barbra Streisand’s “Evergreen” and the Carpenters’ “Rainy Days and Mondays”), said the word can be difficult to deploy without seeming too flowery.

“I think the reason ‘rainbow’ worked for me is because it’s followed by a really hard word,” Williams explained, referring to the consonants in “connection.” “And I’m 30 years sober, so when I talk about ‘connection,’ I know what that means.”

For all its reassurance, Musgraves’ “Rainbow” shares some of that duality; after all, she’s speaking to the listener as the latter is “stuck out in the same old storm again.” What elevates the song above a feel-good pep talk is that it’s not promising that pain can be avoided; it is acknowledging pain’s inevitable place in the spectrum of experience suggested by its title.

“It’s like ‘Over the Rainbow’ in the sense of: Is this a happy song or a sad song?” McAnally said. “It goes back and forth.”

“Rainbow” didn’t fit on Musgraves’ next album, 2015’s “Pageant Material.” But in demo form the tune had quickly become a favorite of her maternal grandmother’s; when the older woman died, “Rainbow” took on a special meaning for Musgraves. Later, she showed the song to producers Ian Fitchuk and Daniel Tashian as the three were working on “Golden Hour.”

“We both welled up with tears when she played it,” Fitchuk said. “It was like, ‘That 100% has to be on the album.’” Musgraves had written the song on guitar, but Fitchuk thought it might work “like a classic Randy Newman song if we did it in a piano-based way.” Recording in a barn at Sheryl Crow’s place in Nashville, Musgraves would cut “Rainbow” live, with Fitchuk accompanying her on piano, at the end of each night’s session; they considered adding strings or some other embellishment, “but it never seemed right,” Fitchuk said.

Eventually they accumulated a dozen or so takes, then picked the best one for the record. In Musgraves’ vocal performance you can hear an emotional wisdom — a familiarity with high, low and everything in between — that echoes Dolly Parton, McAnally said, and indeed there’s something both refined and folksy about her singing, as though she’s putting her personal spin on some eternal cosmic truth.

As they did with “Follow Your Arrow,” Musgraves’ fans cottoned to “Rainbow” right away when “Golden Hour” came out. But the song didn’t get a big commercial push until nearly a year later, in early 2019, when the singer — for whom country radio has never been a source of strong support — was due to perform the song on the Grammys.

Dungan recalled a meeting with programmers from the powerful iHeartMedia conglomerate in which he said he told them, “There’s a good chance that she could win album of the year, so the question is: Are you gonna own this or are you gonna stay away from it?” A number of stations ended up spinning “Rainbow,” he said, but ultimately the song fizzled on the airwaves — a victim, in Dungan’s telling, of the country format’s entrenched aversion to downtempo material.

No matter. Musgraves’ Grammys win boosted the singer — and “Rainbow” — to a new level of visibility well beyond country music. Fitchuk remembered hearing “a whole field of people singing along to it as the sun went down” at Tennessee’s Bonnaroo festival last summer; at Christmastime, the producer was surprised to encounter the song in a children’s theater production he attended with his wife and kids.

Now, just a few months after those holidays that already feel like ancient history, “Rainbow” has taken on yet another life.

Asked about his experience having written a song that outlived its original context — one that’s provided comfort similar to that which “Rainbow” is providing during the pandemic — Williams chuckled.

“It’s what I call a heart payment,” he said. “First you make some money off it if it does well. Then maybe down the line this wonderful evolution happens, and you get parents coming up to you saying, ‘This is my daughter Debra, and Debra can sing every word of ‘Rainbow Connection.’

“I think that’s what Kacey’s got ahead of her with this song.”

———

©2020 Los Angeles Times

Visit the Los Angeles Times at www.latimes.com

Distributed by Tribune Content Agency, LLC.