It seems like the final destination for a Jew is heaven ("Olam Haba") if he behaved properly. What then is the purpose of the resurrection of the dead and how does it differ from heaven?
Olam HaBa, the world to come, is a generic term in Torah. The specific context must be taken into account in order to understand the meaning.
In some places it refers to the world of souls, that place where the soul goes after departing the body. This is what you are referring to as "Heaven".
In other places it is referring to the world of resurrection. After this world, meaning Olam HaZeh, and after death when the soul departs this world and enters the world of souls, a universe that is neither material nor corporeal.
What follows these first two stages is a transitional period which is called the days of Moshiach. And following that state of being is the time of the general resurrection of the dead which is the most common meaning of Olam HaBa, the world to come.
In the time of the general resurrection, all souls of the Jewish people return from the non-corporeal world of souls to be enclothed anew in their resurrected, physical body.
This terminology and order is specified at the end of the "HaKol Yoducha" prayer said after Barchu on Shabbat morning.
For a lengthy and detailed discussion of this subject, see the Chassidic discourse of the Lubavitcher Rebbe that begins with the words, "Lahavin Inyan Techiyat HaMetim" in volume three of Sefer HaMa'amarim Meluket published by Kehot.