It doesn’t have to be this slow or expensive.
A sprinter train from Berlin to Munich, which is a similar distance, takes a bit less than 4h, non Sprinter is 1h more with Tickets starting at 17.50€
But this starting price can be had only if you book way in advance. If you hop on the train from Berlin to Munich today, it will set you back between 93€ and 135€.