Is there a heaven and hell?
What does the Tanakh teach about the afterlife?
The Hebrew Bible does not say much about the afterlife. Daniel 12:2 is the only verse where it is mentioned clearly.
Daniel 12:2 And many of those who sleep in the dust of the earth shall awake, some to everlasting life, and some to shame and everlasting contempt.
This verse speaks about the resurrection of the dead which will happen in the last days according to the book of Daniel, this results in everlasting life for the righteous and everlasting contempt for the wicked. Notice that it does not say that the wicked people will be alive but says that the righteous will enjoy everlasting life. The wicked people are not going to hell, they will be shamed and held in contempt by the righteous and will then cease to exist which separates them from God. The Tanakh does not have the concept of an eternal hell like in Christianity or Islam where people suffer.
The Hebrew Bible also talks about a place called Sheol that people go upon death where they are resting and cannot praise God, this is an older view and is mentioned in the Torah, Psalms and the book of Job. Job prays for God to hide him in Sheol to get relief from his suffering. Jacob, Saul and Samuel all went to Sheol when they died.
Genesis 37:35 And all his sons and all his daughters rose up to comfort him; but he refused to be comforted; and he said, For I will go down to Sheol to my son, mourning. Thus his father wept for him.
1 Samuel 28:19 And the LORD will also deliver Israel with you into the hand of the Philistines; and tomorrow shall you and your sons be with me; the LORD also shall deliver the camp of Israel into the hand of the Philistines.
Psalm 6:6 For in death there is no remembrance of you. In Sheol who shall give you thanks?
Job 14:13 O that you would hide me in Sheol, that you would conceal me, until your wrath is past, that you would appoint me a set time, and remember me!
People did not want to go to Sheol, not because they were frightened of eternal punishment, but because they wanted to continue to praise God, which they could not do in Sheol. From all this it is clear that the Hebrew Bible emphasises this life over what will happen when we die. This life and how we behave towards God and how we treat others now is more important. God wants us to serve Him and worship Him because we want to, not because we are frightened of hell or want a reward in heaven.