Ransomware uses encryption to lock the files on an infected computer. Encryption is the same technology that protects your credit card numbers when you shop online. With the encryption key, you can read the contents of the locked files. Without the key, though, the files only look like a mess of random characters. It's impossible to extract any useful information from an encrypted file.
Some people have managed to regain access to their encrypted files following a ransomware infection by paying the ransom demands. However, it is important to remember that the people who spread ransomware are criminals. Even if you do pay the ransom, there is no guarantee that you'll receive the encryption key. It's better to avoid ransomware entirely if you can.