Here's one of the hundreds of articles about this, it's a very well documented phenomenon https://www.newscientist.com/article/2414241-writing-things-...
Writing by hand also has a greater effect than typing because it engages more of the senses and more of the brain, in particular the motor cortex.
I keep telling myself that this would all make a great excuse to get a Moleskine, but handwriting just isn't a part of my workflow. Typing copious amounts of stuff into text buffers and then transforming it is, especially now that we have LLMs. If my brain is totally non-functional I simply start typing barely intelligible phrases into a text editor until it wakes up, then I go back and edit/refactor/clean up, and frequently something comes out of this that looks like a vague outline of an email or piece of code I need to write that day. Or at least a todo list. Then we're off to the races doing actual work. Most of the initial doodling is destroyed.
Handwriting does aid retention though.