We simply don’t know how language originated. We do know that the ability to produce sound and simple vocal patterning appears to be in an ancient part of the brain that we share with all vertebrates, including fish, frogs, birds and other mammals. But that isn’t human language.
We suspect that some type of spoken language must have developed between 100,000 and 50,000 years ago, well before written language (about 5,000 years ago).