It's not so much that they forgot how to write, as that writing lost its function. The writing system known to the Greeks of the Late Bronze Age, a syllabic script known as Linear B, was primarily used as an administrative tool by the palace elites that ruled Mycenaean Greece. In the 12th century BC, when this societal organisation collapsed and regional government disappeared, there was no longer any need for written records. It is possible that palace scribes passed on the ability to write within their families for a few generations, but since there was no longer any demand or use for their skill, it was eventually lost altogether. For something like 400 years (c. 1150-750 BC), there is no evidence of the existence of writing anywhere in the Greek world.
The reintroduction of writing is not a well-attested history, but it is clear that the new writing system (the Greek alphabet) had no relation to Linear B. Instead, it was closely related to the Phoenician alphabet, and even the Greeks themselves believed that they had learned their letters from the Phoenicians. The 8th century BC provides a reasonable context for this knowledge transfer; the Phoenicians traded throughout the Mediterranean at this time, and they feature prominently as traders and travellers in the earliest works of Greek literature. How exactly the alphabet was adopted and transformed by the Greeks is not known, but it is likely that this happened in one of the various multi-ethnic trading ports established across the Mediterranean, where Greek traders and settlers would have mingled with Phoenicians. It is not surprising that some of the earliest known Greek alphabet writing, the inscription on the Cup of Nestor, was found in the trading settlement at Pithekoussai, on an island near modern Naples.
There are some answers to these questions here already, for instance: https://www.reddit.com/r/AskHistorians/comments/2eh7hm/have_we_found_the_origins_of_linear_script_b_yet/cjzklcq/
Basically, before the Bronze Age Collapse, the Greeks were using an alphabet that is today called "Linear B". After the collapse, it was forgotten, and the Greeks later adopted Phoenician script which is not related to Linear B.