The role of the bass player largely falls into a few areas:
To outline the harmony
To provide the low end
To support the music and the other musicians in the band
To supply the rhythm alongside (primarily) the drummer
Don't forget melody as that plays a part too in terms of hooks, riffs, fills, and memorable parts.
The bass guitar is the bridge between the three main elements that make up music:
Listen to your favourite bass lines and you'll hear these elements at play. When you start to get a handle on them and you can really hear and analyse a bass line, try to mimic what you like in your own playing.
Make sure to scroll down for the free backing track and PDF.
Vultures (Live) - John Mayer
Due to a copyright claim, unfortunately, I had to remove the clip I was going to show you. No worries, here it is below. It starts at the bit I was mentioning but you should listen to Pino Palladino's playing throughout the whole song.
Backing Track & Arpeggio PDF
Learn the arpeggios above and then download the backing track. Follow the bass drum pattern and keep things simple. Root notes (the red blobs in the diagrams) are your friend!
F# Minor Pentatonic can be used as fills as can some of the notes within the arpeggio.