Firstly there is an unresolved bug which can cause passengers to flood a vehicle up to 4 times their actual capacity. For example A train that could sit 400 people and a few dozen overcrowded held 2,000 people. When this occurs all class logic breaks down so such situations can be ignored. It is not resolved because of the limited ability to recreate it and there is currently a much more serious issue that is being dealt with.
What is meant to happen is that passengers will choose the cheapest comfortable class that they can afford. So for example say the train has the following made up classes with appropriate comfort values.
High : 2 hours
Medium : 1 hour
Very Low : 30 minutes
A High wealth passenger who is going to ride the train for 1 hour 15 minutes will pay for a High ticket and go into the High class because he will reach his destination in comfort and can afford to.
A High wealth passenger who is going to ride the train for 45 minutes will pay for a Medium ticket and go into Medium class because it is comfortable enough.
A High wealth passenger who is going to ride the train for a short 15 minutes (eg the next stop) will pay for a Very Low ticked because it is comfortable enough.
Things get more tricky when it comes to when they cannot ride comfortably to their destination, either because the journey is too long for the comfort of any available class or because they cannot afford the lowest class that would be comfortable for their journey. The exact logic I do not know, and is not clear. It is described to be that a passenger might buy a more expensive ticket for better comfort but might also stick with the cheapest since he will not be fully comfortable anyway.
Now of course this is not at all realistic. The result is a lot of wealthy people taking very low, literally stuffed into the back of a coal car, type of classes just because the next stop is very near so "comfortable" or too far for more expensive classes to be comfortable for. A Very High passenger would pay for a High ticket if available just to avoid getting their cloths dirty or being associated with riffraff. The class system also does not allow one to promote passengers up classes such to fill more seats with lower class tickets, something very common with air travel. It is very common for airlines to promote frequent fliers up a class of seating, eg Business to First Class, if seating is available to allow them to sell another Business or lower ticket just to fill up the plane.