The afterlife doctrine of the Israelites changed over time. It was affected by the surrounding nations. At first, the Israelites did not believe in an afterlife. Obedience to YHWH was rewarded by a happy, prosperous life. You may recall the Sadducees did not believe in a resurrection.
Later they changed their beliefs and adopted the doctrine that in the future all the faithful would be brought to life on Earth in fleshly bodies. You may remember that the Sadducees tried to trick Jesus in regards to their question about a woman who was married to all seven brothers. They asked Jesus which brother would be married to the woman after they were all resurrected.