Differences, uses, and theory of volatile and nonvolatile memory?
Yes, you understand the definition of volatile and non-volatile memory.  From that alone you'd think non-volatile is always better.  However, in the real world that is not true since the different technologies for making these memories cause other attributes to appear beyond volatileness.

Tradeoffs that various different memory technologies force on us include:

Read speed.

Write speed.

Cost.

Size.

Power consuption when idle, reading, and writing.

Operating lifetime.

Number of lifetime reads or writes.



and that's just what came to mind quickly.  Obviously, the ideal memory is fast to read, fast to write, costs little, is small, takes little power, lasts a long time, and can be used many times.  There is no one technology that does a good job in all these areas together.  Volatileness is just one more entry in the list of parameters to consider.

In something like a microcontroller intended to be embedded into a circuit that needs to turn on quickly, having the main program memory be non-volatile is imortant.  That today generally means it will be slow to write, have a finite number of lifetime writes, and will forget its content after a few 10s of years.  Obviously we'd like to not have these drawbacks, but nobody knows how to make a memory that doesn't have them for the size and cost required in a micro.

The data memory in a micro could be arbitrarily written and read in a loop millions of times in seconds, possibly going on for years, so a technology that doesn't have a finite number of lifetime reads or writes is important.  To get that, we give up the ability to retain the values when power is removed.

There are all kinds of memory technologies that optimize some of these parameter, inevitably at the expense of others.  Some common technologies:

CMOS static RAM.  These are really logic circuits optimized to hold bits.  They are fast, have effectively infinite lifetime reads and writes, take little power when not being accessed, and have a long operating lifetime.  On the other hand, this memory is volatile, and the cells are relatively large, which makes them expensive with high densities not attainable.

EEPROM.  Actually that's not strictly speaking a technology, but today (this could easily change) these memories are commonly implemented with floating gate MOSFETs.  Their main attribute is that they are non-volatile.  Density is high, so cost is low, but they get physically worn out a little bit every time the charge on the gate is changed, which is what writing or erasing does.