ok data is stored at some address in the ram but why we are doing this?The programmer decides what he wants to do with the RAM, it basically is not necessary for a cpu to work, think of it just like any other peripheral.
Have you ever written a program for PC? In any program you will have some variables, and the content of those variables is stored at some address in the RAM. The compiler decides what those addresses are and writes these addresses directly into the code. So when a line of code says i=i+1; the compiler rewrites it to Read data from address 123456, Add 1 to it, Store the result to address 123456.