I had to check the source, of course, and inevitably it is a bit more complicated. It is from “Rights of Man” (1791) and the original is
“In stating these matters, I speak an open and disinterested language, dictated by no passion but that of humanity. To me, who have not only refused offers, because I thought them improper, but have declined rewards I might with reputation have accepted, it is no wonder that meanness and imposition appear disgustful. Independence is my happiness, and I view things as they are, without regard to place or person; my country is the world, and my religion is to do good.”
But you can understand how the popular reversal into “The world is my country, and to do good is my religion” is more modern.
However, 1791. Still so much to learn!
I found an interesting analysis of this phrase on everything2.com
More from Thomas Paine at wikiquote.