It's my understand the Dalvik cache is a place where the Android OS re-compiles the executable programs the first time to optimize them. It only needs to do it once which explains the "cache" part -- unless you make a major change like replace the kernel. If you do that, you want to manually clear the Dalvik cache to force Android to recompile the apps for the the new kernel.
I also believe the main data Cache is used by the Android OS at runtime to write temporary files for specific reasons. You want to clear this out when you try a new ROM so it doesn't re-used that cached data.
Manually clearning both caches out allows the new ROM to be installed in a "cleaner" environment.
FYI - there is also a Battery "cache" of sorts where the OS keeps battery statistics. You want to clear this every once in a while -- especially if you're experiencing fast battery drains or change batteries.
Anyone feel free to correct me if I'm wrong.