In the show, Nellie sings this song after being convinced that despite the racial differences between her and Emile, there is good in him. And so she is elated to be in love with him.
Rodgers and Hammerstein were as inspired by Mary Martin's personality as they were by the character of Nellie Forbush to write this song. They introduced it to Mary Martin one night when they were at Joshua Logan's house fine-tuning the script. Hammerstein wrote this song to express the exuberance of Nellie's character at this point in the show, and it carried over to Mary Martin's performance of it. Unusually, he did not use her native Texas, as he felt that the use of Kansas alliterated better with the k sound of the word corny. Mary Martin was so thrilled that when she sang it on stage, she performed cartwheels on the stage at every turn of "I'm in love."