So in the Old Testament, there is a passage where God kills all the first born of Egypt because the Pharaoh will not release the Hebrew slaves.

Also in that passage, it states that the Pharaoh was actually prepared to release the Hebrews (due to the previous less severe plagues), but God hardens Pharaoh's heart, and makes him refuse just so God can show off his powers.

Is this ethical?

Did God just commit mass murder against Egyptian children to show off his powers?

How do Jews, Christians and Muslims (which I think all believe in most of the Old Testament), rationalize this?