From the Merriam-Webster Online Dictionary definition of melody: 1 : a sweet or agreeable succession or arrangement of sounds 2 : a rhythmic succession of single tones organized as an aesthetic whole
The second definition is more narrow & precise. But still not enough. Let’s go a bit further. A melody is a succession of musical notes (pitch-specific, properly intonated tones) constructed in such a manner as to be perceivable as a self contained unit. A good melody should have these characteristics & in addition should be goal-directed by implying a harmonic context/framework.
It can also be useful to add further qualities in order to refine our definition. A good melody should also have a healthy variety in vertical dimensions (up & down motion, variety of interval steps & leaps) as well as horizontal dimensions (rhythmic values). It can be helpful to have a single high point & or low point but it is not always necessary. Any number of nursery rhymes & childrens tunes are good examples of bare-bones, simple, but good, melodies (i.e.: “Mary Had a Little Lamb”, “Twinkle, Twinkle Little Star”, “London Bridge is Falling Down”, etc.).
They are good examples because they have clear, direct succession of tones, they imply a harmonic progression (even though only one note at a time is used!) & as a consequence of implying harmonic content, they are goal-directed. There is a healthy variety in various dimensions. For example, they typically have a “question” phrase that ends on a dominant (half-candence) & then an “answer” phrase. This is usually a variation on the first phrase starting similarly but ending on the tonic (full candence). Harmonic implication as a means of providing a goal is essential.
Sometimes a melody is broken down into smaller parts (or phrases or sections) that are altered, variated, used in different manners. These are typically known as themes, motifs, variations, etc. For example, the melody may be fully stated once, then broken down into smaller components. These smaller components are then used in various ways to create variations, developments, new sections, themes, sometimes whole new melodies.
See this page for more on melody with examples.