Was it a tell? A plug? A piss-take? Last November, in Los Angeles, Pharrell Williams was wrapping up a press day at the Beverly Hills Four Seasons. In a knitted cap, several chains and a very visible orange camouflage print, Williams had managed to maintain his well-documented good nature after answering many, many stupid questions.

The sweetness of many of his hits means Pharrell is every wedding DJ's best friend

Williams was there to promote Hidden Figures, the surprise smash he co-produced. (The film has just won the Screen Actors Guild Award for outstanding performance by a cast, an upset that may be predictive of events at the Oscars.) Unless you worked at Nasa in the 1960s, the story of Hidden Figures would, until recently, be news. The Friendship 7 mission, the one that took an American (John Glenn Jr) into orbit for the first time, could not have happened without three African-American women: Mary Jackson, Dorothy Vaughan and, most especially, Katherine G Johnson, who helped plot the re-entry arc for Friendship 7 with hundreds of calculations made by hand.

These women helped put Americans into space. Since he’s a fan of being first, I asked Williams if he would go to Mars with Elon Musk. “That guy’s a genius, but I would not go to Mars,” Williams said. He then looked at the black square on his wrist and said, “I’m going to definitely be watching that Mars trip in brilliant pixelation on one of my Apple devices.”

Williams seems way too canny to drop a plug into an interview. Was he mocking the idea of product placement, or being self- deprecating about how mainstream and openly commercial his career has become? If the latter, that would be an unusually bitter note from a perennially sweet human being. Williams has already achieved a professional success that seems to follow its own set of biological rules. He was able to come up with both the earth-shifting beat for Clipse’s 2002 single Grindin’ and the hold music bromides of 2014’s Happy, the biggest-selling single of 2014. Sales figures are impressive, but that’s not what made people trust Williams. They trust him because of songs like Grindin’, which could be a recording of two people beating on opposite ends of a rusted-out Cadillac, a song that broadened what pop could sound like.

People also trust Williams because he is implausibly calm, impractically handsome and deeply persuasive. Although his own singing voice is more pleasant than powerful, he served as a coach for The Voice in the US between 2014 and 2016.

Hidden Figures is the second movie Williams has been intimately involved in. The first one was 2015’s Dope, commonly referred to as an ode to black nerds. Hidden Figures extends that film’s function – to correct history and bring lesser-seen characters into the light – and both are as wholesome and precise as Williams is. Corrections, both slight and extreme, are what Pharrell Williams provides.

Facebook Twitter Pinterest Father figure: Pharrell with his wife Helen Lasichanh. The couple had triplets in January. Their first child was born in 2008. Photograph: Charley Gallay/Getty Images

In May, Williams will co-chair the Met Gala, along with Anna Wintour, Katy Perry and Rei Kawakubo, the designer whose work is the focus of this year’s exhibition. “She’s the illest, the greatest, the best – your favourite designer’s favourite designer,” Williams said of Kawakubo.

Your favourite producer’s favourite producer hasn’t hit many bumps, but the few detours have been significant. Nobody, including Williams, defends his first solo album, In My Mind, in 2006. And in 2015, right after the success of Happy, Williams and several others lost a lawsuit filed by Marvin Gaye’s family, reportedly to the tune of $7m. Gaye’s family – and plenty of others – thought Robin Thicke’s Blurred Lines bore more than a passing resemblance to Gaye’s Got To Give It Up, and the courts agreed. As co-writer and producer, Williams was caught up in one of the highest-profile music trials of the 21st century.

Since then, Williams has been slowly transforming a musical profile into a celebrity brand, a counter-intuitive but effective way of ensuring the standing of a remarkable musical run. He began his career in the neighbourhood of Hampton Roads, Virginia. As a teen, he met another musician, Chad Hugo, at a summer camp for gifted kids. In the early 1990s, they formed a band called Surrounded by Idiots, with local DJ Timmy Tim (best known as Timbaland). Hugo and Williams broke off soon after and became a live band, the Neptunes. One of Williams’s first jobs was writing Teddy Riley’s verse on Rump Shaker, the enormous 1992 hit by Wreckx-n-Effect. Twenty-five years on, Williams has co- produced or appeared on Snoop Dogg’s Drop It Like It’s Hot, Jay Z’s Frontin and Daft Punk’s Get Lucky, to name a few out of several dozen songs that will be able to balance out the glycerin saturation of Happy. Williams is a wedding DJ’s best living friend, and deserves all the lifetime achievement awards he will likely receive before he hits 60.

Facebook Twitter Pinterest Hats off: with Jay-Z and Beyoncé at the Grammies, 2014. Photograph: Mark Davis/WireImage

When I first met him in 2003, at the Four Seasons in New York, Williams was just as friendly, but less guarded. “Man, I’d rather just be in the studio right now, listening to Burt Bacharach, trying to find some new chords nobody’s put together,” he told me, leaning forward on a couch in the enormous lobby. After our interview, he was meeting with designers who were helping him launch the first sneakers for his Ice Cream clothing line. They looked liked Stan Smiths with decals stuck to them, amateurish at best. But soon both Ice Cream and his other line, Billionaire Boys Club, were established streetwear lines. Groundwork was being laid. Pop careers rarely last beyond 40.

When I was young I'd ask things like: where is the end of space? What's the farthest to the left or right?

Williams has managed to kick off several variations on a second act, more Harry Belafonte than Jay Z. Hidden Figures is an excellent way to move away from court cases and into a larger cultural position. Though he had little to say about making music in 2016 – “I’ve been in the studio, cooking” was his entire report – he was genuinely excited about Hidden Figures. We were exactly one week away from the American election.

Mimi Valdés, one of Williams’s main collaborators and the executive producer of the film sat beside him, quickly calling up facts on her phone, sometimes anticipating what Williams was going to ask. “The book wasn’t written when we were doing the movie,” Valdés offered. “Donna Gigliotti optioned Hidden Figures when it was just a 55-page book proposal.” Williams nodded calmly while his eyebrows hiked up. In his even-keeled world, this signalled excitement.

Facebook Twitter Pinterest Winners and losers: a selfie with Hillary Clinton on her presidential campaign. Photograph: Jewel Samad/AFP/Getty Images

“This story involves the plight of the African- American woman in the 1960s, our culture, the culture divide, the gender divide, and Nasa, which I used to visit as a kid,” Williams said. “I’ve always been obsessed with space, since I was young. I asked things like: ‘Where is the end of space? What’s to the farthest right or left of space?’ And all of this took place in Hampton Roads, Virginia. Mimi knew I was going to lose my mind and be obsessed with this story. That was true and I am. We’ve been on this journey ever since.”

Williams had his hand in almost all of the music heard during Hidden Figures. For the score, he collaborated with Hans Zimmer, as he has done several times. (For any normal person, this side gig would be the job of a lifetime.) He contributed several songs to the movie, the most significant of which is Runnin’. We first hear the song when Johnson is running from her desk all the way back to West Computing. The line Williams uses in both the verse and chorus is, “Don’t act like you was there when you wasn’t.” As affable as both Williams and this film is, the message here is not ambiguous: “Like our 2017 movie, but don’t pretend you were our 1962 friends.”

Before he wrote any of the movie’s music, Williams visited the set in Atlanta. “I went because I just wanted to soak in everything for the music. I wanted to make sure I was pulling in all the energy – not just the energy of the story, but the energy of the actors.”

Facebook Twitter Pinterest In vogue: with Anna Wintour at a Louis Vuitton private dinner. Photograph: Patrick McMullan/Getty Images

His love of Nasa became concrete in his youth. “I used to date a girl who worked there,” he reported. “They had this section called ‘microgravity’. They were in charge of growing things out in space, plants and cartilage and stuff, when they realised it was growing faster out there. This girl was interning for the microgravity department, so I’d always be up there all the time.”

Is microgravity what Williams uses to grow whatever he does? The comment reminds me of a time, a year earlier, when I travelled with Williams to his home in the hills of LA. After leaving the set of The Voice, Williams was running behind schedule, but was eager to discuss the origins of one of his earliest productions with Hugo, Superthug, the 1998 song by rapper N O R E. He brought up non-western tunings, slam dancing and bumper cars as inspirations – for a piece of music. After listing all of these entirely disparate elements, he looked directly at me and said: “How can we put that into what we’re doing?”

I used to date a girl who worked for Nasa. She interned in the microgravity department

In retrospect, this seems the key to Williams’s work. He doesn’t necessarily need music to be his main vehicle. After brushing aside questions on this part of his work, he enthusiastically launched into a description of how he’d brought together the small textile company Bionic Yarn and G-Star Raw to use plastic to create fabrics. “You can make polyester by repurposing existing plastic, whether it’s from the ocean or the land,” he explained. “The ocean has so many problems – dumping all of the toxic nuclear waste, all the dumping of the mercury, these are huge issues. Plastic is just one way we can help.”

Suddenly the Apple comment sounded different. Maybe those devices will be his, in every sense of the possessive, soon.

Hidden Figures is out on 17 February