There is a Hadith which says “Every government before Imam Mahdi is illegitimate.” What is the taawil of this Hadith?

One meaning is that anyone who rises and claims he is ruling on behalf of God or representing the Prophet, then their government is not a legitimate one. Hence, all the caliphs who have ruled for the last 1000+ years have been illegitimate.