Another explanation is that he told Saul what had happened, and a Gadite told him to make David king while he was alive, because only a king and a court can ask the Urim and Thummim, and anyone who needs the support of the community can do so. And David was asked with the Urim and Thummim. Once he heard this, a spirit of jealousy entered his heart. How do we know this?
Because it says in the same passage, "When you gave him bread and a sword, you were conspiring against me." Saul was not satisfied with this, and he asked him by God, and that is why Ahimelech died. As soon as he saw Saul's angry face, Ahimelech replied to the king and said, "Who among all your servants is as faithful as David?" Saul said, "Neither him nor anyone else."
At first, Ahimelech had refused to ask God on Saul's behalf, saying that he had begun to inquire of God that day, and he had not yet been authorized to ask. However, Saul did not want to accept this and insisted that Ahimelech had to ask God for him. Saul then sentenced Ahimelech to death for having sought the support of the Urim and Thummim on David's behalf. Immediately, the king commanded his guards to attack Ahimelech, but they refused to obey him.
This illustrates the verse, "Whoever keeps a command will not experience harm" (Ecclesiastes 8:5). This refers to Abner, who did not allow the priests to be harmed, as it says, "My lord's servants did not lift a hand against the priests of the LORD" (1 Samuel 22:17). Once he saw that they didn't listen to him, he said to him, "Worry about yourself. You have spoken harshly with your sword."
As it is said (1 Samuel 22): "And the king said to Doeg, 'You turn around and strike down the priests.'" So he stood up and killed them, as it is said (1 Samuel 22): "And on that day he killed eighty-five men." See what courage he had, that no one in the world helped, but he himself killed them. And not only them, but also (1 Samuel 22): "And he struck down Nob, the city of the priests, with the sword."
David cried out and said, "What glory is it to you to speak evil, you mighty one? All day long you plot destruction." He said to Doeg, "A strong man and the head of the Sanhedrin is busy with this evil, speaking ill of others. In this mighty act of evil, he is strong."
He said to him, "This is true strength: when one sees his friend on the edge of a pit and pushes him in, or when he sees him on the roof and pushes him off. That is strength. But when is one truly strong? When his friend is about to fall and he grabs his hand so he won't fall.
And also when he sees his friend falling into a pit and he lifts him up." And you saw that Saul was angry with me and threw water on my limbs (perhaps it means into the well). That is true strength, which a person does. All day long, he shows kindness.
He said to him, "Do you think that if we had not received Ahimelech and he had not given us a portion, there would not have been anyone in Israel to give?" Indeed, the people of Israel are accustomed to doing kindness all day long.