A melody is like a sentence in English. Some words carry more emphasis; some notes carry more emphasis (longer notes, notes at the beginning of a measure, etc. ). You find a chord that fits the notes with emphasis. For example, if an important note is E, try out chords that contain E in any position in the chord.