The answer to your question is contained in I Samuel 15. Saul had been ordered by God to fall upon the Amalekites (descendants of Esau) and utterly destroy them, every man, woman, child and beast.
So listen now to the message from the LORD. This is what the LORD Almighty says: ‘I will punish the Amalekites for what they did to Israel when they waylaid them as they came up from Egypt. Now go, attack the Amalekites and totally destroy[all that belongs to them. Do not spare them; put to death men and women, children and infants, cattle and sheep, camels and donkeys.
This message was delivered to Saul by Samuel, God's prophet. Saul did attack the Amalekites and destroyed them utterly, however he captured Agag, the King of the Amalekites and kept him as his prisoner. He also had his men keep the best of the cattle and sheep. This was in disobedience to God's explicit command that nothing was to be spared. Saul ostensibly planned to use these as a sacrifice to God. God then informed Samuel that he regretted having made Saul King. Samuel reprimanded Saul, who again argued that he had saved the best animals to sacrifice, to which Samuel replied:
Does the LORD delight in burnt offerings and sacrifices
as much as in obeying the LORD?
To obey is better than sacrifice,
and to heed is better than the fat of rams.
For rebellion is like the sin of divination,
and arrogance like the evil of idolatry.
Because you have rejected the word of the LORD,
he has rejected you as king
Saul then begged Samuel for forgiveness, which was not forthcoming. When Samuel turned to leave, Saul grabbed the hem of Samuel's garment and ripped it. Samuel then said to him:
The LORD has torn the kingdom of Israel from you today and has given it to one of your neighbors—to one better than you. He who is the Glory of Israel does not lie or change his mind; for he is not a human being, that he should change his mind.”
So, Saul did not follow God's explicit command, and ultimately lost his kingdom as a result.