There was an old priest name Eli, who had two sons, Hophni and Phinehas. Like Eli, his sons were priests, but they were bad priests who didn't know God, stole meat from burnt offerings, and had sex with women at the door of the tabernacle.
The sons of Eli were sons of Belial; they knew not the LORD. 1 Samuel 2:12
If any man said unto him, Let them not fail to burn the fat presently, and then take as much as thy soul desireth; then he would answer him, Nay; but thou shalt give it me now: and if not, I will take it by force. 2:16
Eli ... heard all that his sons did ... how they lay with the women that assembled at the door of the tabernacle of the congregation. 2:22
Eli talked to his sons about it and tried to get them to change their ways, but they wouldn't listen to him since God had already decided to kill them.
They hearkened not unto the voice of their father, because the LORD would slay them. 2:25
Before killing Eli's sons, though, God tormented Eli a bit. First, a "man of God" tells Eli that God will "consume his eyes" and "grieve his heart" and make sure that all of his descendants will die young.
A man of God ... said unto him, Thus saith the LORD ... I will cut off thine arm... There shall not be an old man in thine house for ever ... I shall ... consume thine eyes and ... grieve thine heart. 2:27-33
Then, just in case the first message didn't get through, God sends another one to Eli through the boy prophet, Samuel. It takes God three tries to deliver the message, but he finally does. And it's the same nasty message: God will make everyone's ears tingle by punishing all of Eli's unborn descendants for the sins of his sons.
The LORD said to Samuel, Behold, I will do a thing in Israel, at which both the ears of every one that heareth it shall tingle. I will perform against Eli all things which I have spoken ... I will judge his house for ever ... because his sons made themselves vile, and he restrained them not. 3:11-13
Samuel delivers the message to Eli and he responds the way believers always do. (God can do whatever he wants -- however absurd, cruel, or unjust -- and they will call it good.)
It is the LORD: let him do what seemeth him good. 3:18
So now God had to figure out how he was going to kill Eli's sons.
And that's where the Philistines came in. God used them to kill Eli's sons, along with a 34,000 Israelite soldiers.
In the first battle, the Israelites lost 4000 men.
The Philistines put themselves in array against Israel: and when they joined battle, Israel was smitten before the Philistines: and they slew of the army in the field about four thousand men. 4:2
Which surprised the heck out of the Israelites, since God was supposed to be on their side.
So they went to get the ark of the covenant, figuring it would protect them from the Philistines.
When the people were come into the camp, the elders of Israel said, Wherefore hath the LORD smitten us to day before the Philistines? Let us fetch the ark of the covenant of ... that ... it may save us out of the hand of our enemies. 4:3
Along with the ark, they also got Eli's sons, Hophni and Phinehas.
So the people sent to Shiloh, that they might bring from thence the ark of the covenant of the LORD ... and the two sons of Eli, Hophni and Phinehas, were there with the ark of the covenant of God. 4:4
When the ark came to the Israelites' camp, they all shouted at once, causing an earthquake.
When the ark of the covenant of the LORD came into the camp, all Israel shouted with a great shout, so that the earth rang again. 4:5
The earth shook so much that the Philistines felt it at their camp, and they knew just what it meant. God was with the Israelites and he was on their side.
The Philistines were afraid, for they said, God is come into the camp. And they said, Woe unto us! for there hath not been such a thing heretofore. 4:7
The Philistines had heard what God did to the Egyptians and they were afraid that now he'd do it to them. So they all said together: "Woe is us."
Woe unto us! who shall deliver us out of the hand of these mighty Gods? these are the Gods that smote the Egyptians with all the plagues in the wilderness. 4:8
Then they snapped out of it and started to act like Philistines, and killed another 30,000 Israelites.
The Philistines fought, and Israel was smitten, and they fled every man into his tent: and there was a very great slaughter; for there fell of Israel thirty thousand footmen. 4:10
And, in the process, they also killed Eli's sons.
The ark of God was taken; and the two sons of Eli, Hophni and Phinehas, were slain. 4:11
Just as God said he would do in 1 Samuel 2:25
(I gave God credit for 34,002, 34,000 Israelite soldiers and Eli's two sons: Hophni and Phinehas.)