Every new and successful example, therefore, of a perfect separation between the ecclesiastical and civil matters, is of importance; and I have no doubt that every new example will succeed, as every past one has done, in showing that religion and Government will both exist in greater purity the less they are mixed together.
Madison here speaks to his own understanding then, in the late 18th century and early 19th, of "religion". In context it means only the sectarian differences between the Abrahamic religions, mostly of Christian sects, with a shading of Jewish and Muslim influence, and even of Deism. In any case it does NOT include atheism or even agnosticism. Today, anything but atheism or humanism aka secular humanism is viewed as "religion".