This is a “fair question” and it deserves a “fair answer.” I believe Scripture will teach us why Saul was punished for his act, but David was not. Since you mentioned David first, we will examine the passage you are referring to. Let’s read 1st Samuel 21:1-6: “Now David came to Nob, to Ahimelech the priest. And Ahimelech was afraid when he met David, and said to him, ‘Why are you alone, and no one is with you?’ So David said to Ahimelech the priest, ‘The king has ordered me on some business, and said to me, “Do not let anyone know anything about the business on which I send you, or what I have commanded you.” And I have directed my young men to such and such a place. Now therefore, what have you on hand? GIVE ME FIVE LOAVES OF BREAD in my hand, or whatever can be found.’ And the priest answered David and said, ‘There is NO COMMON BREAD on hand; but there is HOLY BREAD, if the young men have at least kept themselves from women.’ Then David answered the priest, and said to him, ‘Truly, women have been kept from us about three days since I came out. And THE VESSELS OF THE YOUNG MEN ARE HOLY, AND THE BREAD IS IN EFFECT COMMON, even though it was sanctified in the vessel this day.’ So the priest GAVE HIM HOLY BREAD; for there was no bread there but the showbread which had been taken from before the LORD, in order to put hot bread in its place on the day when it was taken away” (NKJV).

Previous chapters leading up to this reveal that David was “running for his life” from King Saul who was determined to kill him. In 1 Samuel 19:18 we learn that David sought refuge at Ramah with Samuel and later he was helped by Saul’s son Jonathan (chapter 20). In our passage he is in Nob seeking help from Ahimelech the priest.  He and his men were very hungry and in desperation David did lie to the priest in order to receive food (by pretending to be doing the king’s business), but David was not guilty of eating “sanctified bread.” Why? Because God, in His mercy, allowed him and his men to eat it because of their dire circumstances. Ordinarily only the priests were allowed to eat it (see Leviticus 24:5-9) but God made an exception in this case. The Lord Jesus put His “stamp of approval” on this in Matthew 12:1-6. In that passage Jesus and His disciples were hungry and were accused of breaking the Sabbath for plucking grain (verses 1-2). His response to the Pharisees is enlightening, “Have you not read what David did when he was hungry, he and those who were with him: how he entered the house of God and ate the showbread which was not lawful for him to eat, nor for those who were with him, but only for the priests? Or have you not read in the law that on the Sabbath the priests in the temple profane the Sabbath, and are blameless? I say to you that in this place is One greater than the temple. But if you had known what this means, ‘I desire MERCY and NOT SACRIFICE, you would not have condemned the guiltless. For the Son of Man is Lord even of the Sabbath’” (verses 3-8). This clearly proves that David was GUILTLESS because God was showing him MERCY.

Regarding Saul, I would ask you to read 1st Samuel, chapter 13. Saul was with his army at Gilgal who were surrounded by the armies of the Philistines. They were afraid and were waiting for Samuel who had told them he would come to Gilgal to offer sacrifices to the Lord (see 10:8), but in desperation Saul became impatient as he waited for Samuel and thus we read, “So Saul said, ‘Bring a burnt offering and peace offerings here to me.’ And he offered the burnt offering” (verse 9). Samuel appeared to him immediately after this and Samuel rebuked him, “What have you done?…You have done foolishly. You have not kept the commandment of the LORD your God, which He commanded you. For now the LORD would have established your kingdom over Israel forever. But now your kingdom shall not continue. The LORD has sought for Himself a MAN AFTER HIS OWN HEART, and the LORD has commanded him to be commander over His people, because you have not kept what the LORD commanded you” (verses 11, 13-14). If you read the whole account of Saul’s life you will see that time and time again, he disobeyed the Lord’s commandments (see chapters 14, 15, 22, and 28), and he was guilty of repeated attempts to murder David (chapters 18-26). His HEART WAS NOT RIGHT, and the Lord determined to replace him with one whose HEART WAS RIGHT. That man was DAVID!  (DO)  (550.1)