@Lamphun_Lamyai Hi and welcome to Talkbass.
Before doing anything else, I would recommend a method book such as the Hal Leonard Bass Method by Ed Friedland - the 'Complete' edition (ISBN 10 0-7935-6382-8) will keep you busy for a while. I would also recommend getting a book on basic theory and functional harmony. Something like "Alfred's Essentials of Music Theory" (ISBN 13 978-0-88284-897-6)
But to your question :-
In terms of function, the first role of the bass is to provide the 'bottom' of the harmony. For the most part this involves sounding the root of the chord, and often doing so on the downbeat. After that, the bass 'line' typically tries to create motion between the chords without upsetting the harmony*.
Taking your example of a simple I-IV-V progression;
- Line A is a basic but harmonically 'correct' line that simply states the roots of the chords at each change without making any rhythmic implications;
- Line B is similar but adds a second low root note to the V chord. This adds some rhythmic push which, combined with approaching the upcoming C chord from below, creates forward momentum;
- Line C develops the idea further by adding in other Chord Tones - see how bar 9 includes the C, E and G of the C major triad. It then brings in the idea of Resolution - see how in bar 10 there is a step-wise approach (C->D->E) to the F in bar 11. Likewise in bar 11 there is a step-wise approach and resolution onto the root of the G chord in bar 12;
- Line D takes this idea further still, reversing the direction of step-wise motion in bar 14 then using ascending step-wise resolution from G back up to C in bar 16. Ascending resolution (B->C) is typically more powerful and 'final' than descending (D->C);
- Line E includes a bit more rhythmic pulse and also introduces the idea of a melodic descent from F to G in bars 19/20;
- Line F is another possible variation that uses the notion of undulating and ascending lines to anticipate the end. See how the last note in bar 24 is B, which is the 'leading tone' of the key and provides the strongest resolution onto the last C. The last C is doubled in the low octave for even more 'finality', but that's just a matter of taste,
View attachment 7091392
See how in most of these examples the root note of the chord always appears on the beat 1 of the bar. The exception is the last bar of line [E] - Can you hear how this changes the rhythmic and harmonic stability of the line, opening possibilities of going on to a chord other than C, or perhaps delaying the ending like this:
View attachment 7091396
What you will see in all of this is that the bass line is as much about
"where are we going?" as it is about
"where are we now?".
* To understand how easy it is for the bass to change harmony, think about this. Everyone in the band is playing the notes of a C major chord (C, E, G), then you come along and play a big fat A low in the bass. Suddenly that chord is no longer C major, it is Am7, with no-one else having done anything. So care is needed not the change the chords.