Riding the Alaska Railroad to Denali is THE way to go! Yes, it's 7+ hours; however, well worth it. Driving would take 5+ hours and you would not get the incredible views you get from the train. Riding the train is very "old school"; no digital tickets; no apps. People checking your luggage, adding tags to your place of accommodation in Denali, paper boarding passes and lots of friendly smiles! Riding the train is a very social and enjoyable experience!
If possible, book the Gold Star service (it's pricey and worth it). On the train, there are 2 Gold Star "cars", you sit up top with a dining car beneath. From Anchorage to Denali you will be served breakfast and lunch. The train leaves at ~8:30am; however you probably won't eat breakfast until 10:00am or 10:30am and lunch until 2pmish, so plan accordingly. At meals you are sitting with other people from the Gold Star cars which creates a very social atmosphere. The Gold Star cars have covered viewing areas at the back of each car; great for picture taking and getting fresh air. There is also a bar in each of the Gold Star cars.
You are encouraged to walk through the train (2 engines, a baggage car - not accessible), 2 Gold Star cars (only accessible to Gold Star passengers), a Bistro car and 2 other passenger cars (fully accessible). Tour Guides provide narration as you travel North to Denali. Everyone on the train is encouraged to point out wildlife (we saw 4 moose). A highlight and great picture opportunity is the trestle across Hurricane Gulch which is over 900 feet long and ~300 feet high. For safety reasons the train moves slowly over the trestle which allows for great picture taking and views over the side of the train.
The views get better the further North you go; once you get North of Talkeetna things really open up. If you are fortunate, you may even get a glimpse of Mount Denali (only 30% of visitors actually see it).
Friendly staff roam the train answering any & all questions. Bathrooms are in every car and easily accessible. Maximum speed of the train is 60 mph.