The Tur, Rabbi Yaakov ben Asher writes in his commentary on Shemos 9:12 that G-d had to harden the heart of pharaoh, in order to prevent that pharaoh would capitulate prematurely. This because G-d wanted wanted to complete the whole series of plagues in Mitzrayim.
ויחזק ה', “the Lord strengthened the heart of Pharaoh.” It is possible that during the preceding plagues the presence of and encouragement by the sorcerers had helped Pharaoh to maintain a defiant posture. Now G’d had to strengthen his heart so that he would not capitulate prematurely, and G’d could not complete the whole series of plagues He had planned. Ibn Ezra writes that Pharaoh did not ask Moses to pray to G’d on this occasion because the plague did not last long, and we should not assume that because the first plague had lasted for seven days, that all the subsequent plagues also lasted for a whole week.
The idea of the Tur is echoed by Rabbeinu Bahya:
Had G’d not interfered at this point, Pharaoh might have capitulated and perhaps would have decided to let the Israelites go.
I might be missing something, but to me it seems that if the Jewish people were taken out of Mitzrayim earlier, that would be better, since they wouldn't need to wait any more longer. However, "Now G’d had to strengthen his heart so that he would not capitulate prematurely, and G’d could not complete the whole series of plagues He had planned.".
This article suggests, based on Kabbalah, that the Jews were being prepared in Mitzrayim to receive the Torah on Har Sinai. The conditions in Mitzrayim served as a "purifying tool" so to speak. Had pharaoh let the Jewish people go before the plagues ended, the process would've not been enough.
Any thoughts on this? Please provide sources.