Most important to understand is that Ransomware is a type of Malware. In that respect, it is not entirely accurate to say that they are different, it is rather than Ransomware has some extra characteristics over and above typical Malware.
Essentially Malware is a form of cyber-attack that tricks an individual into installing software onto their computer. Once installed this software allows cyber criminals to access your files and even track your actions. In addition, if Malware gets into a computer that is connected to a corporate network it can be intelligent enough to find other non-protected computers on that network ad start spreading across multiple machines.
Malware is usually distributed by email or social media messages encouraging people to download something of interest, perhaps a codec file purported to be required to view a video or maybe something that appears like a free application or game. The Malware will be inside the executable that is downloaded and in many instances the user may have no idea they have been infected.
Once installed the cyber-criminal gets access to your computing habits and can also access your data. They can use both to access bank accounts, pay for items using your credit card or even set up new bank or utility accounts in your name. Worse they may even sell your information on to other criminals.
Ransomware is a type of Malware that infects you using the same methods as typical malware. However once infected rather than stealing your information, Ransomware encrypts your data and prevents you from accessing any of your information. It will then display a message demanding a payment (usually in bitcoin) to unlock your data. Unfortunately given that ransomware is sent by cyber criminals there is no assurance that your data will be unlocked even if you pay.