Is it possible to rent a car in Prague and drive to Krakow
Yes, of course it is possible if you wish to drive. It's around 330 miles from Prague to Krakow, taking (in theory) just over 5 hours (expect it to take longer). www.viamichelin.com will give you route, route info, estimated timings and route alternatives.
You'll need to check with the rental company beforehand that taking the car outside the Czech Republic is ok (most allow this) and may have to pay an additional premium for doing so.
If you decide not to drive there are, obviously, trains between the two cities. There is one direct (i.e. no change) daily departure taking just under 8 hours plus several which involve a change of train. The official German railway website in English carries official information about almost all European trains and will give you departure times and details:
Mentioned in this answer: