As one speaks into a can, the other listens in the other can. You' ll be surprised at how well this works. Talking causes little vibrations in the air in front of your mouth, as you can tell by speaking into your hand. When you send those vibrations into the can, they cause the back end to vibrate. This vibration is passed along the string and into the other can.
Tin can telephones are fun to make, and they're a great way to learn about how sound works.