These two Hadeeths are under the chapter of seclusion from people in times of fear of tribulation. The first Hadeeth is on the authority of Aboo Hurayrah (may Allah be pleased with him) that the Prophet ﷺ said: 'Allah has not raised any prophet except that he tended sheep'. That is, there was no prophet whom Allah – the Mighty and Sublime - sent to His slaves except that he watched over sheep. They said: 'And you?' He ﷺ replied: 'Yes, I tended them for a few carats from the people of Makkah'.
The scholars explained that one will learn the manner of looking after people and guiding them to what is good for them from tending sheep. This is because the shepherd will occasionally lead the herd to a good grazing land and at times to inferior pastures, and sometimes to a land completely different from the above-mentioned lands. Besides, he may not even take them out for grazing and he may keep them inactive at other times. The Prophet ﷺ guided this Ummah to what is good of knowledge, guidance and illumination as the shepherd who has good knowledge of superior grazing lands and good sense will take his flock to good spots- where the sheep will have their fill of pasture and drink.
The sheep was selected because shepherds are generally benevolent, gentle and laidback unlike cameleers who are usually harsh and wicked because what they rear is also harsh and wicked. Therefore, Allah- the Mighty and Sublime - chose the sheep for His messengers to rear in order to learn how to look after people.
So the Prophet ﷺ tended sheep for some people of Makkah for some carats while Musa (عليه السلام) tended them as a bride-price for the daughter of that native of Madyan. Thus, he said:
“He said: “I intend to wed one of these two daughters of mine
to you, on condition that you serve me for eight years, but if you complete ten years, it will be (a favour) from you.” [Al-Qasas: 27].
Likewise, the second Hadeeth also contains evidence that seclusion may be good. A man will take hold of the bridle of his horse and bolt towards a place where he has heard the call to Jihad. In so doing, he will be far away from those people guarding the frontiers of the Muslims; he is concerned about Jihad. Although he is far from people but on a high state of alert for mobilisation for Jihad such that every time he hears the call, he will ride on his horse and gallop to where the call has emanated; that is, he will go there swiftly.
So also is he who is in a place within the valleys or the mountaintops, secluded from people, worshipping Allah– the Mighty and Sublime; he is not among the people except as a person who is full of goodness, then this is good.
All the same, we have earlier mentioned that all these narrations are to be understood as referring to when there is evil and tribulation in mixing with people. However, if such does not exist, a believer who mixes with people and patiently bears their harms is better than the one who does not mix with them and does not experience patience due to their harm.