For many millenia religion likely acted as a glue to hold society together. Yeah, you had your Inquisitions and Crusades and such, but whenever someone posits the above they NEVER bother to explain what other societal organization and body of norms would have replaced it in that function, across many thousands of years and innumerable cultures, so as to get us to an equivalent point today. You can’t simply drop modern philosophies (as in a time-traveling philosopher maybe) into the Mongol, Egyptian, or Roman Empires and expect everyone to suddenly forgo all of that.
Yeah, in the 21st century it (as in mythic religion) has certainly overstayed its welcome, and among most modern secular societies it has seen a steady decline over the past half century+, so said process appears to finally be in motion, precisely because the conditions for it to finally fade only recently came into play. In any event there are extensive readings on this topic and since this is IMHO and not GD I’ll stop there.