The story of Yiftah's Daughter is one of the more famous and tragic events in Shoftim, Judges, which is already full of tragic and dreadful events. On the surface it appears to be the tragedy of a man making a foolish vow. There appears to be no larger context to it.
But to understand the meaning of the story, we need to go back to the beginning.
Yiftah (Jeptah) is called back to lead the fight against the Ammonite invaders and he writes a letter to the King of Ammon, which is one of the first examples of diplomacy.
While Yiftah's background might make you think that he would like a fight, he tries to talk things out with the Ammonite king. After relating the story of how the disputed territory came into Israel's possession, he tries to turn all that history into something the King of Ammon can relate to.
"Wilt not thou possess that which Chemosh thy god giveth thee to possess? So whomsoever the LORD our God hath dispossessed from before us, them will we possess." (Shoftim 11:24)
For a guy who lived a nomadic life and probably didn't have much of an education, Yiftah is pretty smart. He's establishing a common legal principle. "When you seize territory and credit Chemosh for it, that's your principle for claiming ownership. Now if we took land, that means our G-d gave it to us and you have to respect His decision."
Yiftah, in his diplomatic overture, had failed to make the proper distinction between G-d and Chemosh, acting as if there was some equivalence. Going to war, the Spirit of G-d comes on him and he makes a pledge that is just as dangerously lacking in distinction. He pledges that the first thing to come out of his gate will be a sacrifice to G-d. That first thing turns out to be his daughter.
G-d does not accept human sacrifice... however Chemosh was worshiped with human sacrifices.
The King of Moav in Melochim Beit offers a human sacrifice in the form of his son. Because Yiftah had failed to distinguish properly between God and Chemosh... he ended up offering his own daughter as a human sacrifice, not to G-d, who does not want human sacrifices, but to Chemosh.
Once his daughter came out, Yiftah could have saved her and himself by realizing who G-d is and what the difference between Him and Chemosh is. Instead he acted as if G-d, like Chemosh, wants human sacrifices. And that inability to distinguish between G-d and an idol to which people gave the blood of their children was the fatal flaw that doomed him.