Moses commanded the Israelites not to marry a gentile in Deuteronomy 7:
3 Do not intermarry with them. Do not give your daughters to their sons or take their daughters for your sons,
God wanted Samson to pursue a gentile woman in Judges 14:
1 Samson went down to Timnah and saw there a young Philistine woman. 2When he returned, he said to his father and mother, “I have seen a Philistine woman in Timnah; now get her for me as my wife.”
3His father and mother replied, “Isn’t there an acceptable woman among your relatives or among all our people? Must you go to the uncircumcised Philistines to get a wife?”
But Samson said to his father, “Get her for me. She’s the right one for me.” 4 (His parents did not know that this was from the Lord, who was seeking an occasion to confront the Philistines; for at that time they were ruling over Israel.)
Did God want Samson to violate a statute of Moses? Did Samson sin?
As suggested by חִידָה's comment: Why would YHVH cause an Israelite to violate His Torah?