1 Kings 3:1
And Solomon made affinity with Pharaoh king of Egypt, and took Pharaoh’s daughter, and brought her into the city of David, until he had made an end of building his own house, and the house of the LORD, and the wall of Jerusalem round about.
Solomon made a political alliance with Pharaoh king of Egypt and sealed it by taking Pharaoh's daughter as wife and bringing her into the city of David. By joining Israel to a heathen nation through marriage to an idolatrous princess, he violated God's law and departed from God's command and provision that Israel remain separate from other nations. The union was a rash and sinful marriage.
Hoping the princess would be converted was a weak excuse that did not justify or excuse the marriage. His wife was later converted. Although the marriage appeared to bring benefits to Israel, including Pharaoh capturing Gezer and giving it to his daughter and Solomon fortifying it, these gains and apparent success did not justify the alliance or make the forbidden alliance safe.
Solomon wrongly trusted in his own wisdom and example to turn his heathen associates from idolatry and to draw the surrounding nations toward God. Instead, the alliance exposed him to influences that set evil influences in motion, began harm, and undermined his loyalty to God and contributed to his loss of loyalty. Although he could have worked to restrain the harm his choice had begun, he later pursued further political and commercial alliances, often sealed by marriages to heathen princesses, and followed the customs of surrounding nations instead of God's commands.