I’m not even going to try and explain this one. Here’s a link to a really good article on REI that breaks it down. And here is a link to a decent Bike Fit Calculator on Competitive Cyclist.
I always see people riding bikes that don’t fit them, or riding bikes that COULD fit them but are set up incorrectly. The risk that you run riding a bike that doesn’t fit you is back pain, knee pain, elbow pain, neck pain, twitchy steering, lack of control, risk of looking stupid, and hating biycles. I strongly recommend you check out the two aforementioned links before you buy any bike.