I understand after each punishment He tells us to be good, do good so we can achieve His mercy. But isn’t faith in Him based on pure love? If I fear His punishment at all times, how could my love be unconditional for Him? I understand if I don’t want to displease God, I have to avoid the bad things that He forbade, because that is for my own good. But why would I have to be always so afraid? In a book of love and mercy, it’s hard to see such punishments, because as for me, if I love God, I would aim to refrain from those things that may hurt me.
To complete the answers:
To inter heaven the person must be pure and perfect. Punishment is because of the mercy of God to pure the one who has infected himself by his own will.
Therefore, in chapter al-Rahman, hellfire has been counted as one of the blessings of Allah.