It can have a secular purpose and have a relationship to God because God was presumed to be both over the state and the church, and separation of church and state was never meant to separate God from government.
The basic premise of the Constitution was a separation of powers and a system of checks and balances because man was perceived as a fallen creature and would always yearn for more power.
But today, government is taking those rights from us, pretending that it gives us our rights. Indeed, those rights come from God, and it was recognized throughout our history as such.
The whole basis of the Constitution was a restriction of power, and the whole basis of the federalist system was that there was not one sovereign centralized power from which all authority flows.
The forefathers, including James Madison, felt very strongly that the duties that we owe to God were outside of government's prerogative, that government had no business interfering with the way we worship God.