Every Spirit has a Doppelganger Nightmare counterpart, why would Riku be the exception to this rule? Replica Riku is Sora's nightmare. it makes even more sense considering Sora's concern of Riku being consumed by the darkness again and his negative experiences with Riku.
Plus, Ansem-Riku is a Xehanort when you really think about it... even Vexen's Doppelganger. Riku Replica is literally a replica of Riku when he was Ansem-Riku. Xehanort could have recruited him as a Seeker of Darkness so that Riku Replica develops his identity beyond a "pathetic imitation".