How did Cantonese and Mandarin end up with the same characters, but completely different spoken languages?


It is believed that Cantonese and Mandarin share the same roots [1]. The Chinese language used in Tong and Sung Dynasty is similar to Cantonese [2]. This is because some of the big ancient wars had forced the knowledgeable Han families to move southwards. They brought their language to Southern China [2]. Meanwhile, Putonghua is highly influenced by Manchurian and Mongolian [2]. It is generally considered easier to learn than Cantonese [2].
Although the written words are identical, the primary difference is in pronunciation, where Cantonese has 6 tones and Mandarin has 4.  [3]  Otherwise, the grammar and vocabulary are based on the Chinese used in ancient China, Classical Chinese. [1]  However,  over time the spoken language diverged further and further away.  [1]  Eventually, in the early 20th century, Chinese reformers saw the need for language reform and  championed the development of a vernacular that allowed modern Chinese to write the language the same way they speak.  The vernacular language movement took hold, and the written language was standardised as vernacular Chinese.  [1]