A dangerous sex offender has been brought to justice after an investigation into allegations of rape spanning almost three decades.