From Middle English rightwise, rightwis, from Old English rihtwīs ("righteous, just; right, justifiable"), corresponding to right + -wise. The second element was later confused with or assimilated to -ous, leading to the modern spelling righteous.
Presumably from Old English rihtwīs, reinforced by reanalysis as right + wise.