The first sentence means that no person other than Ram can play tennis. You may have many friends who play games, but none of them, except Ram, can play tennis. They may play other games, but not tennis. The second sentence, on the other hand, means that tennis is the only game that Ram can play. He cannot play any other game. Your other friends may play cricket, table tennis, badminton, etc, but Ram cannot play any of these.
Here are a few more examples. *Only Geetha likes the Physics teacher. (No other student likes the teacher.)
*Geetha likes only the Physics teacher. (She doesn’t like any other teacher.)