Take "Yesterday" for example. Possibly the most famous tune of all time and Paul just fell out of bed with it running in his head one morning.
We can talk about it all we want: how it begins with an expressive 2-1 appoggiatura, how the phrase length is irregular, how the harmony falls from I to a minor, not diminished, VII for a Lydian modal effect, how the final cadence is plagal, how the relative minor is tonicized in the second bar and so on. But trust me, a hundred other composers could do the same things (and have) and come up with tunes that are banal, inexpressive and unmemorable. This is where theory fails.
I once got into an argument with a theory professor who was trying to claim some sort of scientific validity for theory. If we study and analyze enough sonatas, then we can come up with a general or typical structure for sonatas and test that model by using it to create new sonatas. If they sound like the old ones, we have a good theory of sonata form. Sounds good in theory... But the truth is that all the really good sonatas are each unique and that is perhaps the crucial element in a great sonata: that it is unique. Take this one for example:
There is no other piano sonata that sounds like that even though Beethoven used a variation on a very old harmonic progression and probably stole the texture from a Mozart opera.
Just so you don't feel completely cheated with this post, where so far I have simply said I have no idea, let me say two things about melody. From the beginnings of notated music in the West, melodies tended to move by step with leaps being far less common. As tonal harmony developed in the 17th and 18th centuries this started to change and by the Classical Period, melodies were typically constructed using the notes of a chord or triad, that is to say, instead of moving by step, they moved by thirds. For example:
As opposed to the stepwise movement of this:
Now here's an interesting thing: the melody of "Yesterday" moves almost exclusively by step, one scale note to the next. Hmm...