You raise several questions.
In semi reverse order of your asking them:
- Is displaying "In God We Trust" on US currency unconstitutional?
No. Not according to the US Courts system, which the U.S. uses for constitutional interpretation. See, for example, Aronow v. United States, where the ruling included:
It is quite obvious that the national motto and the slogan on coinage
and currency 'In God We Trust' has nothing whatsoever to do with the
establishment of religion. Its use is of patriotic or ceremonial
character and bears no true resemblance to a governmental sponsorship
of a religious exercise. ...It is not easy to discern any religious
significance attendant the payment of a bill with coin or currency on
which has been imprinted 'In God We Trust' or the study of a
government publication or document bearing that slogan.
- Why do the courts not rule it unconstitutional
Because it does not establish a state religion, which is what the first amendment bars Congress from doing.
- Why is this motto written on US currency?
The motto started out on coins.
The motto first appeared on the 1864 two-cent coin following collaboration between the Mint Director, the Secretary of the Treasury and Congress to place the motto on that coin. Further legislation from Congress in the 1860s and 1870s allowed the motto to be used on additional coins. And since 1938, it has appeared on all US coins.
Later, in 1955 Congress passed a law that "'In God We Trust' ... shall appear on all United States currency and coins".
So, the reason the motto is written on US currency is that Congress passed a law saying it would be.
- What politics are in play here?
The U.S. Department of the Treasury speculates the motto made its way onto coins in the 1860s because:
The motto IN GOD WE TRUST was placed on United States coins largely
because of the increased religious sentiment existing during the Civil
War. Secretary of the Treasury Salmon P. Chase received many appeals
from devout persons throughout the country, urging that the United
States recognize the Deity on United States coins.
The move to add it to paper currency in the 1950s coincides with Congress establishing "In God We Trust" as the national motto, establishing an annual National Day of Prayer, and adoption of the Pledge of Allegiance which includes the phrase "One nation, under God". All of this happened at a time when the U.S. was facing off against the atheistic communism of the Soviet Union, which I suspect was the driving popular/political force -- to differentiate the United States as having a capitalistic and deistic ideology.
- Did the founding fathers dislike the idea of religion "in the system"
The Constitution only mentions religion in the first amendment, which bars Congress from establishing a State religion. In that regard, the Constitution is a secular document - it certainly does not establish some sort of theocracy.
At the same time though, other founding documents like the Declaration of Independence make explicit appeals to a Creator.
Furthermore, while the amended Constitution forbade establishing a Federal State Church, many individual U.S. States had State Churches during and after the founding period. Connecticut's remained until 1818.
Trying to pin down a consensus of the founders on the appropriate interplay of religion and government is messy. I think an anecdote that captures this well is that the first two US presidents, George Washington and John Adams, both proclaimed national days of prayer as President. But then our third President, Thomas Jefferson refused to do the same, replying to Rev. Samuel Miller as follows:
I consider the government of the United States as interdicted by the
Constitution from inter meddling with religious institutions, their
doctrines, discipline, or exercises
James Madison, the fourth president, resumes the practice. Then it basically ends until the 1950s (right around when Congress decrees "In God We Trust" should go on paper currency).
Similarly, Washington proclaimed an explicitly religious day of Thanksgiving. Then Thanksgiving fell out of practice from 1815 until the Civil War period in the 1860s, where Lincoln puts out a Thanksgiving proclamation that goes so far in regard to religious content that it includes:
They are the gracious gifts of the Most High God, who, while dealing
with us in anger for our sins, hath nevertheless remembered mercy
(And at that same time, "In God We Trust" starts going on coins.)