The RAM hold instructions in machine code, which varies depending on the processor. The volatile part of RAM holds it until it is instructed to be cleared, or the machine is powered off. Other instructions, those in EEPROM, stay in memory. These are sent back and forth to the CPU over the front side bus. There are other things going on, but that's the most basic explanation. ROM = read only memory. It's the storage of data that can't be (easily) erased.
An important distinction is how people refer to memory vs storage. The hard drive is storage, NOT memory.