Theory:

     Disguised as a shepherd and riding on a mule, one day the king came to the cave where the wise shepherd lived. As soon as the shepherd saw the traveller coming towards the cave, he rose to welcome him. He took the tired traveller inside the cave, gave him water to drink and a share of his own meagre meal. The king rested for the night in the cave and was greatly impressed by the shepherd’s hospitality and wise conversation.
 
     Though still tired, the king decided to depart the next morning. He said, “Many thanks for your kindness to a poor traveller. I have a long way to go. Permit me to leave.”
 
     Looking straight into the eyes of his guest, the shepherd replied, “Thank you, Your Majesty, for paying me the compliment of a visit.”
Explanation:
 
The king decided to meet the shepherd. So, he started his journey towards the shepherd's place. Since the king wanted to check his intelligence, he did not reveal his identity. The king dressed as a shepherd and started to ride on a mule.
King riding on a mule.jpg
King riding on a mule

One day, the king reached the shepherd's place. The shepherd lived in a cave since he couldn't afford a cottage of his own. When the shepherd had seen the traveller coming towards his cave, he rose to welcome him. The traveller looked tired as he was riding on his own, from a great distance. He took the traveller inside the cave and gave him water to drink. Being a poor person, the shepherd had limited food in his cave. Still, he felt happy in sharing his food with the traveller. The king was greatly moved by his friendly nature towards a stranger like him. The whole night he conversed with him and was greatly amazed by his intelligence while conversing.
 
King conversing with the shepherd.jpg
King conversing with the shepherd

The king spent a night as a traveller in the shepherd's cave and decided to leave the next morning though he felt tired. He did not reveal his identity to the shepherd; and thanked him for offering a night's shelter in his cave for a poor traveller like him. The king continued to explain the reason, as, he had a long way to travel, he requested the shepherd to allow him to leave.
 
The shepherd listened to his words till this time. Then, he looked directly at the eyes of his beloved traveller and replied to him, “Thank you, Your Majesty, for paying me the compliment of a visit.”
 
Meaning of difficult words:
  
S.No
Words
Meaning
1.
Disguise
 To make changes in the appearance so that people will not recognise you
2.
Mule
An animal used for carrying loads whose parents are a horse and a donkey
3.
Hospitable
Friendly and kind towards guests 
4.
Depart 
To leave a place and start a journey 
5.
Majesty
A title of respect when refers to a king or a queen 
6.
Compliment
Used to express praise or approval
Reference:
National Council of Educational Research and Training (2006). The Shepherd's Treasure (pp. 07-10). Published at the Publication Division by the Secretary, National Council of Educational Research and Training, Sri Aurobindo Marg, New Delhi.