Then the king of Egypt said to the Hebrew midwives, one of whom was named Shiphrah and the other Puah, “When you serve as midwife to the Hebrew women and see them on the birthstool, if it is a son, you shall kill him, but if it is a daughter, she shall live.” But the midwives feared God and did not do as the king of Egypt commanded them, but let the male children live.” (Exodus 1:15–17, ESV)

In this story of brutality from Pharaoh, leader of Egypt, everything hinges on the behavior of two Hebrew midwives: Shiphrah and Puah. [Aside note:  The fact that we know their names is indicative of the fact that this account was written by someone quite familiar with the events surrounding the Exodus and that the pair were held in very high esteem by the Israelites]

Pharoah gives a command to the two midwives to kill every male born of the Hebrews.  This is his solution to the problem that the Hebrews seemed to be having children left and right with no end in sight.  It was the first time that the Jewish nation was under existential threat, it will not be the last.

But the midwives feared God.  Pharoah told them one thing, the moral and righteous thing to do was quite another.  The pair had a choice to make and they chose to fear and obey God.

We sometimes get wrapped around the axle due to the fact that the midwives lied to [or at least mislead] Pharaoh (vs.19). This is a mistake because God blesses them for obeying him (vs. 20).  My nephew has an unpublished manuscript where he delves into this question of lying or misleading for the sake of doing something right.

He writes:

Remarkably, the lie these ladies told occurred within the context of their fearing God.  In other words, even as they feared God so much that they disobeyed the direct order of a powerful monarch, somehow Shiphrah and Puah also felt the freedom to lie.  To resist Pharaoh, they engaged in an action seemingly contrary to the holiness of the God they so honored.

He continues:

 Shiprah and Puah’s actions and subsequent lie forced Pharaoh into a different
course of action.  He ordered the open slaughter of the Hebrews’ male children in an effort to accomplish what the midwives did not.  In so doing, Pharaoh manifested the deep wickedness and corruption of Egyptian society, including its religious practices and its treatment of non-Egyptian refugees.  This action brought to maturation the fullness of Egypt’s sin, and inaugurated the time of God’s open, apparent, and miraculous judgment.  The blatant display of
sin and its heinous extent made God’s righteous judgment all the more glorious, all the more satisfying, and all the more wonderfully holy in its application.  God does not need the justification of man for His action, but God delights to use human agency, even in sin, to exalt Himself.  This exaltation puts on display that which is most precious and valuable in the cosmos, namely God, and calls people of all types into joyful, obedient, and completely fulfilling relationship with Him.   Yes, Puah and Shiprah lied.  But their lie forced sin into the open and
became yet another paving stone on God’s road of redemption.

His conclusion follows:

 The immense, holiness-driven, God-honoring emphasis that Scripture puts on truth is much greater than the mere veracity of one’s speech.  In other words, what it means to “lie” runs far deeper than merely answering the question of whether one’s words are factually true.

Finally, he quotes Sam Storms:

It would appear that there are occasions when deception is ethically permissible.  But note well: not all falsehoods are lies.  A lie is an intentional falsehood which violates someone’s right to know the truth.  But there are cases in which people forfeit their right to know the truth.  The question, therefore, is not whether it is ever morally permissible to lie.  The question is, “What is a lie?”  A lie is the intentional declaration or communication of a falsehood designed to deceive someone who has a moral and legal right to know the truth.  A lie is the telling of an untruth to someone to whom you are morally and legally obligated to speak the truth.  There are, however, certain occasions on which we are not under obligation to tell a person the truth (in times of war, criminal assault, etc.).

Pharoah, by dint of his unethical and immoral command to kill Hebrew male babies simply because they were Hebrew and male, has forfeited his right to know the truth.  He is acting in a way that destroys what God has created and in the process usurped the role of God himself.  There is no obligation to speak the truth to such a man, especially when the truth will result in even more evil.  This is why God blessed Shiphrah and Puah and we should be grateful and thankful that he did.