There is no single rule, and the rules can be quite flexible (unfortunately). I can think of several rules for now,
Rule 1: when possible, try to put your fingers where you don't need to reposition within a bar. For example, in one bar the lowest note is C5, the highest note is F5, you should put your index finger on 3rd fret 1st string, then you can cover the range without needing to reposition the fingers.
I learned this rule from piano, though I don't know how to play piano.
Rule 2: when possible, keep the transition between notes/chords as minimum as possible. For example, if there is transition from Dm(0222) to G(2320), or G to DM, though usually we use 1st, 2nd, and 3rd fingers for G, under such situation, using 2nd, 3rd, and 4th fingers for G will be more convenient.
Rule 3: using pinky finger wisely can make fingering easier. The Dm and G transition example in rule 2 is good case to use pinky, after I realize it, I found using pinky wisely is really useful.