When looking at a score of a song I have always looked at a melody against the notes of the chord root but recently I started learning counterpoint and I feel that I may have overlooked the importance of the melody note against the bass. A bassline may play other notes below any given chord so my question is: If I want to write better melodies, and I am learning by analyzing sheetmusic of my favorite pieces of music and songs, should more priority be given to the melody against the bass as opposed to the melody against the chord?
A 'good melody' is good based on general principles; such as not using multiple skips in one direction, avoiding constant repetition of a single note, etc. However, when analyzing a harmonized melody, you must analyze both the harmony and bass.
The consideration of the bass versus the harmony is not mutually exclusive; the melodic notes chosen should depend on the harmony, but the specific melodic note may be chosen to favor the bass.
Although the melody against the bass is probably more important for Renaissance and Baroque musical styles, composers of every period take the harmony into account. In modern music, especially pop, the melody is much less likely to have any strong relation to the bass.
I'd say not particularly. As a bass player, I may play several completely different basslines under the same melody/chords. Where would that leave you?
The melody of most songs has a greater affinity to the underlying chords at any point - usually there will be at least a couple of melody notes which are found in the chord at the time. This helps a lot, as if the two don't match somewhere, either the chord or the melody will be wrong! And don't just regard it as melody against chord root, as you say. While a simple bass line may well incorporate the root of a chord, that's not even half of the story. And bear in mind that sometimes a chord sequence may appear first, sometimes it's the melody line, sometimes the words, and occasionally everything comes out together. Serendipity!