The melody for Happy Birthday was first penned by two sisters from Kentucky, Mildred J. Hill and Patty Smith Hill. The song was called Good Morning to All, but bore the recognizable melody. The tune was first published in 1893 in the book Song Stories for the Kindergarten. The melody has since passed into the public domain, and is safe to hum in public without permission.
While it is not entirely clear who first wrote down the words for Happy Birthday, it showed up in a few places before Jessica Hill (another Hill sister) was able to demonstrate undeniable similarities between Good Morning to All and Happy Birthday and to secure the copyright to the song.
Working with the Clayton F. Summy Publishing Company, Jessica Hill published and copyrighted Happy Birthday in 1935. While the copyright should have expired in 1991, copyright has been extended repeatedly over the last quarter of the twentieth century and the copyright for Happy Birthday is now not due to expire until at least 2030.
The Clayton F. Summy Company is no longer independent, but, through a chain of purchases, the copyright for Happy Birthday To You lies securely in the hands of the Time Warner company. Happy Birthday's copyright is licensed and enforced by ASCAP, and the simple little ditty brings in more than USD $2 million in annual royalties.
For more information on the history of the tune, lyrics, and copyright status, check out these resources: http://www.unhappybirthday.com/