The "ABC Song" shares a melody with "Twinkle Twinkle Little Star" and "Baa Baa Black Sheep." All three songs are based on another song written in 1761.
In 1761 a composer named Bouin wrote a melody called "Ah vous dirais-je, Maman," according to Lullaby Link. Roughly 20 years later, Wolfgang Amadeus Mozart wrote 12 different variations of Bouin's work. Hearing one of Mozart's renditions, in 1835 an American music publisher named Charles Bradlee adapted the melody and added the words to what is now referred to as the "ABC Song."
The "ABC Song" or "Alphabet Song" was the first to use the melody, but "Twinkle Twinkle Little Star" and "Baa Baa Black Sheep" followed later. Twinkle was a poem written by Jane Taylor and published in 1806, while the poem "Baa Baa Black Sheep" predates the song to which it is set by 30 years and was set to the melody in 1879. The "ABC Song" teaches children the alphabet, while "Twinkle Twinkle Little Star" and "Baa Baa Black Sheep" are nursery rhymes set to music. The latter two are often used as lullabies sung to infants and young children, while the "ABC Song" is sung by older, school-age children.