Miracles leader Smokey Robinson wrote this in about 20 minutes. In a 2006 interview with NPR, he explained that some songs just flowed out of him, and those were often the hits. Robinson wrote the song for another Motown artist, Barrett Strong, but Motown leader Berry Gordy convinced him to record it with his group, The Miracles, and have Robinson's wife, Claudette, sing lead. Gordy worked on the song with Robinson, which was a slower and more bluesy number when the Miracles first recorded it.
The song was released as a single, but late one night, Gordy woke Robinson up with a phone call announcing he thought up a different arrangement for the song and called the group into the studio to record it (it was not uncommon to re-record a song in those days after hearing it on the radio and considering improvements). Everybody made it to the studio except the piano player, so Gordy pounded the ivories while the tape was rolling. The hit version, which had a faster tempo and Smokey on lead, was recorded around 3 a.m.