A “very dangerous” sex offender who exploited a primary school-aged girl has died of cancer in prison.