What level of comfort do the trains in Vietnam provide and how safe are they?
There are five classes on Vietnamese trains: hard seat, soft seat, hard sleeper, soft sleeper and "super berths" (soft sleeper with air-con), though only the long-distance expresses offer the full range. For short journeys hard or soft seat carriages are fine, though most Vietnamese people can only afford hard seat so these carriages tend to be packed out.
For longer journeys, particularly overnight, try and get a sleeping berth. Hard sleeper consists of six bunk beds in one compartment (two tiers of three). In most cases the seats have padding and it's reasonably comfortable; the exception is the night train to Lao Cai, when you just get a hard wooden bunk and a mat to sleep on. Prices for the bottom bunk are highest and the top bunk is the cheapest, partly because you have to climb up and also because there's very little space between the bunk and the ceiling. Soft sleeper compartments have four bunks (two tiers of two) which are all priced the same. Note that sleeping berths get booked up well in advance, so it's best to make your reservation as early as possible.
Meals are provided on longer journeys, though you may prefer to take your own supply of snacks, fruit and bottled water. You can supplement these when vendors come on the trains at stations to hawk their wares.
As far as safety goes, in my experience (as a female travelling alone) the trains in Vietnam are fine. However, theft is becoming more of a problem on some routes, particularly the night trains from Hanoi north to Lao Cai. It's wise to ensure your luggage is locked and safely stowed away, don't leave anything lying near an open window and always carry your valuables with you. In the sleeping carriages the bottom seats lift up and you can put your bags underneath, so these berths are quite a good idea. The only downside is that everyone will be sitting on them during the day - which means you can't stretch out if you want a nap. The top berths have access to a useful storage space above the door.