According to the opinions that it doesn't just mean innkeeper in this context (see this question), does anyone explain why we are told that she was a zonah? She seems to be shown as a very good person in other ways and it seems odd that we need to be told that.
Besides for the more hashkafic explanation brought by @robev and @Dov, there's also a technical explanation, brought by the Malbim and one that I've heard in various classes over the years: As a harlot - evidently a popular one (see, for example, Zevachim 116b) - important people from the city and perhaps all of Canaan frequented her household and so she became very knowledgeable in various matters and was an important source of information. That's why the spies headed to her home in the first place.
Therefore, she was referred to as a harlot so that we the readers would know why the spies went to her house of all places. It was the CIA of the time - Canaanite Intelligence Agency.
Like @Robev stated it is to show how those that come from a lowlier spiritual place have the ability to repent, reach great heights and go on to marry the leader of Klal Yisroel "דְּאִיגַּיַּירָא וְנַסְבַהּ יְהוֹשֻׁעַ" (as per the Gemara in Megillah 14b).
Refer to Megillah 14b which mentions in the same passage that she was a harlot and yet she merited to have a very praiseworthy lineage:
שְׁמוֹנָה נְבִיאִים וְהֵם כֹּהֲנִים יָצְאוּ מֵרָחָב הַזּוֹנָה, וְאֵלּוּ הֵן: נֵרִיָּה, בָּרוּךְ, וּשְׂרָיָה, מַחְסֵיָה, יִרְמְיָה, חִלְקִיָּה, חֲנַמְאֵל, וְשַׁלּוּם. רַבִּי יְהוּדָה אוֹמֵר: אַף חוּלְדָּה הַנְּבִיאָה מִבְּנֵי בָנֶיהָ שֶׁל רָחָב הַזּוֹנָה הָיְתָה
Eight prophets, who were also priests, descended from Rachav the harlot, and they are: Neriah; his son Baruch; Seraiah; Mahseiah; Jeremiah; his father, Chilkiah; Yirmiya’s cousin Chanamel; and Chanamel’s father, Shallum. Rabbi Yehuda said: So too, Chuldah the prophetess was a descendant of Rahab the prostitute.
Indeed, in Pesikta D'Rav Kahana 13 it relates how Klal Yisroel sinned in matters where Rachav was righteous, which again brings out this idea, how she emerged from not-so-great beginnings to become a big tzadekes:
את מוצא כל מה שכת' בישר' לגניי כתוב ברחב לשבח
You find that whatever is written to Israel's discredit / disgrace is written to Rachav's credit / praise.
Finally, the Midrash also demonstrates this idea, that Hashem helped her grow spiritually but only after she took active steps to draw herself close to G-d, thereby illustrating that despite originally being a zonah, she worked on herself to become the person she was and thereby merited to forge a connection with Hashem.
Bamidbar Rabbah 3:2 writes:
רָחָב הַזּוֹנָה קֵרְבָהּ אֲבָל לֹא בְּחָרָהּ, אַשְׁרֵיהֶם אֵלּוּ שֶׁקֵּרְבָן אַף עַל פִּי שֶׁלֹא בְּחָרָן
Rachav the harlot drew herself near, but He (Hashem) did not choose her. Fortunate are those that drew near, even though they weren't chosen.
The Eitz Yosef there helps to explain this:
והנה האבות אברהם יצחק ויעקב כחותיהם היו טובות. אבל לא קירבם ה' בתחילה לסייעם בעשות טוב. כי היו מטולטלים. ורק הם בעצמם התחזקו מאד להתהלך לפני ה'. אבל רחב ויתרו לא נתבחרו כי לא היו כחותיהם טובות. רק ה' קירבן ועוררם ע"י משה ויהושע. ואם כה בבחירה בלא קריבה. ובקריבה בלא בחירה. ואיך אשרי מי שנבחר מצד כחו. ונתקרב מה' לסייעו
Behold, the forefathers Avraham Yitzchak and Yaacov - their strength was good. But G-d did not bring them closer at first to help them in doing good. They had to expend the effort. It was only when they themselves became very strong to walk before G-d. But Rachav and Yisro were not chosen because their strengths/traits were not good, rather Hashem chose and inspired them through Moshe and Yehoshua, and they came close without being chosen. And how blessed/fortunate is he who is chosen due to his strength and will become close to Hashem to help Him.