The term al-khilafa al-rashida (the rightly guided caliphate) was coined around or soon after the time of the civil wars that took place between Imam ‘Ali b. Abi Talib and his opponents.
It was designed to contrast the period of the first 3 caliphs, who were promoted as rightly guided, against the rule of 'Ali who was being denigrated by this comparison.
This will probably come as a surprise to our Sunni friends who clearly believe that ‘Ali is very much a part of the rashidun caliphs.
Yes it’s true today, but it wasn’t the case when this term was coined and the fictitious hadith was invented, amongst so many others, in order to give power to this anti-’Ali propaganda.
Here’s that work of fiction referred to in the question:
“Adhere to my sunnah and the sunnah of the rightly-guided successors after me. Hold on to it and cling on to it stubbornly.”
This narration is recorded by Abu Dawud, al-Tirmidhi and Ibn Majah.
A study of the various chains of narration shows multiple weak and unreliable characters. But notice these ones in particular and see if you can find a pattern.
- Khalid b. Ma’dan b. Abi Karib al-Kitabi - Belonged to Hims, a Syrian town under the rule of Mu’awiya that was notorious for its people's enmity towards ‘Ali, and he was the chief of police of Yazid b. Mu’awiyah!
- Thawr b. Yazid - Belonged to Hims as mentioned by al-Dhahabi (Mizan al-I’tidal, vol. 1, p. 374). As mentioned by Ibn Hajar ‘al-’Asqalani (Tahdhib al-Tahdhib, vol. 2, p. 34) he hated ‘Ali who had killed his father in a battle. ‘Abd Allah b. Mubarak refrained from narrating from him and considered him a heretic (fasid al-madhhab).
- Hajar b. Hajar al-Kila'i - Belonged to Hims and was considered of unknown standing as mentioned by Ibn Hajar al-’Asqalani in Tahdhib al-Tahdhib, vol. 3, p. 118.
So this fake hadith was put in circulation to undermine the legitimacy of ‘Ali. Later, after the fall of the Umayyads and the rise of the ‘Abbasid’s, Sunni theology and creed started to take shape. And the chapter of the hatred of ‘Ali was officially closed.
‘Ali was now considered the fourth of these rashidun caliphs.