Three weeks is plenty of time to see a few different areas. I spent a month there last year and I could go back for another month and still not cover all I want to see. You can spend a few days in both Hanoi and HCMC and fill in the rest with a couple of cities/beach spots in between. I would recommend Halong Bay and Hoi An as definite places to consider but there are a few other spots I didn't get to that people mention around here (Mekong Delta and Nan trang).
The train is an aquired taste IMHO. It's definitely doable and itself an experience but not the most comfortable or efficent mode of transport. Hanoi to Hue is an overnight 12-hour journey so if you are looking to maximize your time I'd suggest flying. The only train ride I would suggest you take is between Hue and Danang (or vise versa). It's about a 3 hour ride and has stunning views of the ocean as you slowly climb the mountain range between the two spots.
Bus travel in Vietnam is also an experience. It's fine for a short 2 or 3 hour trip to a smaller city but anything beyond that would not be fun! Most of the minibuses I took I would categorize under 'harrowing' but still interesting.
I'd leave the tour booking until you get there unless it's something really specific you'd like to see. There's plenty of different tour companies in Hanoi and HCMC who speak English and you can probably negotiate a good price in person. I'd just do some research of the tours you'd like to go on prior to going.
Outside of one night at the Hanoi Sheraton (very nice) I only have experience in budget/mid-range hotels ($30-40US/night) and they were fine. I don't recall any bad experiences and I always had clean rooms and good A/C (you'll want that). Staff was always friendly and I could always find a cheaper hotel in a decent location.
I cannot comment on the UAE layover but if you like architecture I'd consider it!
Dos and don'ts:
Try lots of street food
Don't watch the road while riding a minibus
Wander away from the main tourists areas in the bigger cities (within reason).
Use lots of sunscreen!
Have a great time!