It is one of The Quran stories which has many lessons in morals.
Allah mentioned in Al- Anbiya Surah in Ayah (78): “And [mention] David and Solomon, when they judged concerning the field – when the sheep of a people overran it [at night], and We were witness to their judgement.”
In the era of David, peace be upon him, a quarrel occurred between two people, one of them was the owner of the sheep and the other the owner of the field. The problem was that the sheep entered the field at night and ate it and destroyed it. That caused a loss of the field for that year.
So David (Dawood) decided that the sheep should be given to the owners of the field provided that the price of the sheep is equal to what as destroyed.
When he ruled that and the two opponents came out, he told Solomon their matter, and he said: If I were a judge, I would have ruled otherwise. Then Dawood knew that, so he asked him about his rule. Solomon said: I saw what is more kindly. He judged that the owners of the sheep take the field on which their worker builds and fix it for a whole year until it returns as it was then is come back to its owners. Besides the owners of the field take the sheep and get benefit from their milk, wool, and their offspring during that period. So David admired of his wise son. As a result, he ruled between them so.
In previous story, the two of the judgement were right; Dawood judgement was right because it as concerning on coming back the rights of the owner of the damaged field, in addition to assessing a fine or a compensating from the people who had caused the damage. In the other hand, Solomon’s opinion was concerning on coming back the rights in addition to keep good relations and void causing harm to the other one.
Biographies:
islamweb.comقوله تعالى وداود وسليمان إذ يحكمان في الحرث إذ نفشت فيه غنم القوم
qurannenc.com ترجمة معاني القرآن الكريم – الترجمة الإنجليزية – صحيح انترناشونال