Melodies are the one element of a song people remember, along with the lyrics. Most great songs throughout history (pop, rock, classical, etc.) are constructed on top of a great melody line.
Below videos are a curation on writing better melody lines.
In todays music along side with writing a melody line from notes, sampling is also used to memorable song writing. You can sample your own stuff and manipulate them or check out libraries produced by award winning artists like ours.