PBS Religion and Ethics has a thoughtful paper on the influence of religion and philosophy on Albert Einstein's science.
"In Spinoza Einstein also found a champion for his belief in a deterministic universe that could be understood by human reason. Spinoza's pantheistic philosophy held that the cosmos was an extension of God or Nature and was therefore fundamentally immutable and strictly ruled by cause and effect. Einstein regarded Spinoza's conception of the universe so highly that he committed what he called the biggest blunder of his career in an effort to preserve his own vision of it. In 1915, he inserted an extra term, the 'cosmological constant,' into his theory of general relativity so that it would yield a static universe similar to the one described by Spinoza instead of the expanding one his calculations produced without it."