#Why did the prophet tell a story to the king of Israel?

The prophet told the story to the king of Israel to deceive him, so the king would make a ruling which would result in the forfeit of the king's own life. [20:39-40]