The spoils of the land, the Lord said, were not to be taken by the Israelites. Rather they were to be taken and consecrated to the Lord. Joshua 6:18-19 proclaims thus,
"And ye, in any wise keep yourselves from the accursed thing, lest ye make yourselves accursed, when ye take of the accursed thing, and make the camp of Israel a curse, and trouble it. But all the silver, and gold, and vessels of brass and iron, are consecrated unto the Lord: they shall come into the treasury of the Lord."
Now this was very unusual. The Israelites had become accustomed to taking of the spoils of the land before, and this command may have seemed unjust to many. So when Achan saw some of the spoils, we can understand a little bit more why he would err. It was just so tempting and beautiful, and who would ever notice a few scraps missing from the Lord's goods?
So Achan took of the goods and hid them in his tent. He thought he could fool everyone into thinking he didn't have them. He would have been right too, except for one thing he had forgotten, God sees everything. The people of Ai were able to win the battle against the Children of Israel because Achan took of the accursed thing. It was the only loss in battle recorded during the conquest.
Achan would soon be stoned and burned for his misdeeds, and the Israelites were set to move on with their actions at Ai with the Lord's blessing. They planned an ambush, and Ai fell just as Jericho did. After the ambush, the spoils of Ai were taken by the Israelites, but this time with the Lord's blessing. Indeed before the victorious battle, the Lord said in Joshua 8:2,
"And thou shalt do to Ai and her king as thou didst unto Jericho and her king: only the spoil thereof, and the cattle thereof, shall ye take for a prey unto yourselves."
They get to take the spoil of Ai. In the end, if Achan had just been willing to be patient and obey God through his actions, he would still have received goods. The Lord provides and blesses us when we obey him. Although it may seem that his plan for our life will lead to suffering (and it might), it will work out for a better end.
You can take this thought and look to expect blessings from God in your lifetime, but I think that would be the shallow lesson to learn here. I believe it is much preferable to realize that obeying the Lord provides for a much superior form of reward later in heaven. Your life here on earth may be less than desirable, but this earth means nothing in the long term. Are you willing to patiently obey the Lord, no matter the consequences, knowing that this "Light affliction, which is but for a moment, worketh for us a far more exceeding and eternal weight of glory?" -2 Corinthians 4:17