What is the purpose of reciting Ziyara?

 (Al-Kafi, volume 1, page 451) 

Why do we send our salam upon Rasul Allah & the Imams in ziyara and prayer? 

Some of our companions narrated [mursal], from Muhammad ibn Sinan, from Dawud ibn Kathir al-Ruqi, he said: 

I asked Abi Abdilah (as): 

What is the meaning of ‘Peace upon Rasul Allah’?

He [the Imam] said: ‘When Allah created his prophet, his trustee [Imam Ali], the prophet’s daughter, and all the Imams. 

And when he created their Shi’a, he took upon them a covenant that they patiently endure, persevere, stand on guard, and be mindful of Allah. 

And he promised them to hand them the Blessed Land [i.e, the Levant] and the Safe Sanctuary [Masjid al-Haram]. 

And that he descends upon them al-Bayt al-Ma’mur [the equivalent of Kaaba of angels, located in the seventh heaven].

And to make the al-Saqf al-Marfu’ [heaven above earth] visible to them. 

And to relieve them from their enemies. 

And to hand them the earth that Allah will replace our current earth with on the Day of Judgement - and will give them everything on it, without flaw. [Note: refer to Quran 14:48]’

The Imam said: ‘They face no competition from their enemies, and they will have in it what they want. And the Prophet took the covenant upon all of the Imams and Shi’a by that. 

And thus, the salam upon the prophet is remembrance of that covenant

بعض أصحابنا رفعه، عن محمد بن سنان، عن داود بن كثير الرقي، قالقلت لأبي عبد الله (عليه السلام): ما معنى السلام على رسول الله؟قالإن الله تبارك وتعالى لما خلق نبيه ووصيه وابنته وابنيه وجميع الأئمة وخلق شيعتهم أخذ عليهم الميثاق وأن يصبروا ويصابروا ويرابطواوأنيتقوا الله ووعدهم أن يسلم لهم الأرض المباركة والحرم الآمن وأن ينزل لهم البيت المعمور ويظهر لهم السقف المرفوع ويريحهم منعدوهموالأرض التي يبدلها الله من السلام ويسلم ما فيها لهم، لا شية فيها - قاللا خصومة فيها - لعدوهم وأن يكون لهم فيها ما يحبونوأخذرسول الله (صلى الله عليه وآلهعلى جميع الأئمة وشيعتهم الميثاق بذلكوإنما السلام عليه تذكرة نفس الميثاق