O.E. upriht, from up "up" + riht "right." Similar compounds are found in other Germanic languages (cf. O.Fris. upriucht, M.Du. oprecht, O.H.G. ufreht, Ger. aufrecht, O.N. uprettr). Figurative sense of "good, honest" is first attested 1520s. The noun in the sense of "something standing erect" is from 1742.
Another link between "straight" [right] and being morally good? The erect position is proper to man, not only because he is a biped but a quadruped, but the natural posture is what is healthy for him as well?