The relationship between Lord Shiva and Lord Vishnu is one of achintya-bheda-abheda i.e. inconceivable simultaneous oneness and difference. This inconceivability does not mean that we cannot use our intelligence to understand it, but our intelligence cannot understand it completely. The one absolute truth manifests in multifarious ways for uplifting the conditioned souls. The same absolute truth manifests to control the modes of goodness, passion and ignorance as Lord Vishnu, Lord Brahma and Lord Shiva respectively. In this sense, the non-difference between these three exalted deities (the abheda part) is understood. For the bheda part, they have certain specific and distinctive functions of controlling the different modes.
In this regard, Srila Jiva Goswami states in his Bhakti-sandarbha (216):
शुद्ध भक्ता: श्री गुरो: श्री शिवस्य च भगवता सह
अभेद दृष्टिम तत प्रियतमत्वेन एव मन्यते
“Whenever the scriptures describe the spiritual master and Lord Shiva as being non-different from Krishna, pure devotees understand that this is because of their being most dear to Sri Krishna.”
After passing through the eight material coverings, and after crossing the Viraja (the river that divides the material world and the spiritual world) and the planet of Lord Brahma (the highest material planet), one comes to the planet of Shiva called Shiva-dhama one portion of which, called Mahakala-dhama, is enveloped in darkness; interpenetrating this portion of Shiva-dhama, there shines the Sadashivaloka, full of great light. This Shiva-dhama is situated on the boundary of material and spiritual worlds, its 3/4th portion lying in spiritual realm and 1/4th portion lying in material realm. Here Lord Shiva resides in his eternal form of Sadashiva.
Thus, when the material modes come into contact with Lord Vishnu, by his own sweet will, He takes on the quality of a demigod and also associates with the modes of material nature as Lord Shiva. Although ultimately He is the controller of the modes of material nature, He willingly accepts that contact and that influence. In each material universe, this manifestation of Lord Shiva, as the demigod in charge of mode of ignorance, is not eternal.
Sometimes there are statements from Siva-Sastras and Bhagavat-Sastras, that apparently appear to contradict each other. In this regard, Karttikeya, the son of Lord Shiva, says in Skanda-Purana:
शिव शास्त्र तत ग्राह्यम भगवत शास्त्र योग यत
परमो विष्णुर एव एकस तद ज्ञानम मोक्ष साधनम
शास्त्रानाम निर्णयस्तु एषस तद अन्यन मोहनाय हि
“Accept the verdict of the Siva-Sastras (like Siva-Purana etc) as long as it is in line and in accordance with the conclusions of Bhagavat-Sastras (Srimad Bhagavatam), because there is only one Supreme, Lord Visnu, the knowledge of whom is the only means for liberation. This is the conclusion of all the revealed scriptures and anything else other than this conclusion is meant only for the bewilderment of people in general.”
When Lord Chaitanya visited Lingaraja temple in Bhubaneswar, he danced ecstatically in front of the Shivalinga for the pleasure of His dear devotee and spoke eight beautiful prayers known as Shivastakam glorifying Lord Shiva. These prayers are recorded in Sri Chaitanya Charita Mahakavya, the diary of Srila Murari Gupta. Therein Lord Chaitanya addresses Lord Shiva as the Guru of whole world.
श्री नारद आद्य सततम सुगोप्य जिज्ञासतयाशु वरप्रदाय
तेभ्यो हरेर भक्ति सुख प्रदाय शिवाय सर्व गुरवे नमो नमः
I offer my respectful obeisances again and again unto you, who is forever enquired of confidentially by Shri Narada and other sages; unto you, who also grants favor to them very quickly; unto you, who bestows the happiness of hari-bhakti; unto you, who creates auspiciousness and unto you, who is the Guru of everyone.(Shivastakam 7)
The scriptures describe that to consider Lord Shiva or Lord Brahma on the same level as Lord Vishnu is an offense. At the same time, to consider Lord Shiva as different or independent from Lord Vishnu is also an offense. Therefore, vaisnavas offer Lord Shiva all due respect as the topmost devotee of Lord Vishnu. On the holy occasion of Mahashivaratri, devotees may pray to Lord Shiva to help them progress on the path of Krishna bhakti swiftly. This is the greatest benediction that Lord Shiva is very keen to offer to all living entities.