It probably doesn't take 5 years to make a camera like the R
pers se. It's the culmination of years of development (in a
very interesting PDF linked here Canon mentions that they envisioned DPAF in the late 90s :
https://d25tv1xepz39hi.cloudfront.net/2018-09-05/files/EOS_R_An_Interview_with_the_Developers_.pdf), but the implementation of all that research into a concrete camera probably took far less time. Hardware-wise the R is quite conventional in many ways. It's the software side and the UI that probably took, comparatively to other cameras' development, a longer time as it's quite different from existing Canon cameras. There's been a lot of efforts in that area.
The R using a derivative of the 5DIV' sensor is probably the result of Canon wanting to launch the RF system right now combined with bad timing on their sensors production investments. I do believe that Canon would have preferred to launch that system with a more capable sensor, but that between launching right now with a less capable sensor and launching later with a more capable one, they decided that it was better for them to launch right now. That decision was probably taken quite a while ago.