Short answer: They are two valid spellings of the exact same word, but "cipher" is more common than "cypher".
Long answer:
I just came across this page, which is entitled It’s Cipher, Not Cypher. It says:
###Where did the variants [of cipher] come from?
Where did the variants [of cipher] come from?
The word we know today as cipher originated in the late 14th century from the Arabic word sifr, meaning “zero.” At this point in the English language (Middle English) the spellings of words were not yet explicitly defined, and writers commonly substituted i‘s for y‘s at will, hence the emergence of cypher as a variant for cipher.
However, after the Great Vowel shift and the standardization of spelling in the 15th and 16th centuries, many of the y’s that denoted “eye” sounds in English were replaced by i’s–hence the change of “wyf” to “wife,” and “cypher” to “cipher.”
Even so, cypher is still considered a valid variant of cipher in many orthographic circles today. Cypher is most popular in England, where it first emerged.
Additionally, this graph from Peter Shor's comment shows how "cypher" was the preferred word until the early 19th century, when "cipher" became more popular. This page shows that almost every country nowadays uses "cipher" over "cypher", with the exceptions being Ghana and Nigeria (and that's probably just from a lack of enough data).