I actually know this because I looked it up before.
It's because of back in the day, they used to rhyme nicknames.
The nickname for Richard is Rick, so it became Dick. And it just stuck, for whatever reason. The same applies to Bill being a nickname for William.
Someone do a rhyming nickname for me, quick! My real name is Zachary, but my nickname is Zach.