We dive into the long-lasting debate behind the question.
Let's start by asking: why were there two dynasties in Russia in the first place? It happened because the last legitimate Rurikid tsar, Fyodor Ioannovich, and his wife, Irina Godunova, left no offspring. And by 1598, when Fyodor died, there were no legitimate heirs to the throne. Ivan the Terrible, Fyodor's father, eliminated all Rurikid families that could possibly lay claim to the crown. His other sons and heirs, Ivan and Dmitry, either died or were killed. But couldn't they just elect a new tsar? Why was this such a big deal?
Why was it important for Romanovs to be related to Rurikids?
Tsar Fyodor Ioannovich
In Russia, the tsar's mission was considered sacred. He was anointed to tsardom, taking the oath to protect his land and people. The tsardom as a political institution was created in Moscow, by its Grand Princes. They belonged to the Moscow branch of the Rurikid dynasty, which ended with the death of Fyodor Ioannovich.
The dynastic crisis set in and the Time of Troubles started after Fyodor's death in 1598. Several tsars ruled Russia for short periods - Boris Godunov, False Dmitry I, and Vasiliy Shuysky. However, only Shuysky was a Rurikid and, after his death, Russia had no Rurikid princes who could take the throne. Only the mighty boyar families that served the Rurikid princes were left, and the new dynasty was most likely to appear among them. Whatever it may be, it had to claim at least some relations to the previous one.
But were they actually related?
Roman Zakharyin, the reconstruction of facial image using his skull
State Historical Museum
The Romanovs were an old Moscow boyar family that began serving the Moscow princes in the 14th century, under Ivan Kalita. They had a common ancestor with the Rurikids - Fyodor Koshka ("Cat", apparently a nickname), who was the great-great-grandfather to Ivan III of Moscow, as well as to Roman Zakharyin-Koshkin.
Zakharyin-Koshkin, who gave his first name to the Romanov dynasty, was a person almost unknown to us - only a few sources mention him. However, he was father to two very important people. His daughter was Anastasia Romanovna, Ivan the Terrible's first wife and the mother of the last Rurikid Moscow tsar, Fyodor Ioannovich. And his son was boyar Nikita Romanov, father of Fyodor Romanov and the founder of the Romanov dynasty. Fyodor Romanov, who became Patriarch Filaret of Russia, was the father of Mikhail Fyodorovich, the first tsar of the Romanov dynasty.
Patriarch Filaret (Romanov), Mikhail Fyodorovich's father
It's all simple from there: boyar Nikita Romanov, the founder of the dynasty, was a brother to Ivan the Terrible's wife Anastasia, and so related to Ivan as a brother-in-law. Mikhail Fyodorovich, the first Romanov, and Fyodor Ioannovich, the last Rurikid, had a common ancestor - Roman Zakharyin-Koshkin, father of Tsarina Anastasia and boyar Nikita Romanov. In this way, the two families were indeed related.