In Exodus 2:14, we read, "Then Moses was afraid." After he learned that Pharaoh had heard about what he had done, he fled to Midian. It seems fairly obvious to me that Moses fled to Midian because he was afraid (and rightly so) that the king was going to kill him. With this in mind, how do we explain Hebrews 11:27, which reads "By faith he left Egypt, not fearing the king's anger; he persevered because he saw him who is invisible"?

Fear and faith sometimes coexist. But not Exodus 2!

Hebrews 11 isn't referring to Exodus 2, but to Exodus 12, some forty years later. When Moses led the people out of Egypt, he defied Pharaoh, king of Egypt. In the same way, we too are called to take our stand, never fearing earthly rulers or authorities.