Increasing difficulty: a ramble can be over very gentle countryside, and need not tire you out, a hike suggests a few hills to get over and a longer distance ('it's quite a hike' can also mean "it's quite a long (and inconvenient) distance"), and a trek suggests the lower Himalayas rather than the Yorkshire moors.
As well as the distance and duration, the motivation of the person/s taking part is also relevant.
'Ramble' suggests a relatively relaxed activity. The chance to see pleasant countryside, get a bit of fresh air, some exercise, and conversation with friends are usually important factors. Little if any competition is involved.
A trek is likely to be far more purposeful, arduous, and involve competitive activity, and achievement orientation rather than relaxation. The trekkers are likely to be carrying lots of survival equipment such as emergency rations, medical kits, all-weather clothing, etc. They may be performing some kind of test eg of navigation, endurance and survival skills.
I agree with most of what Linkway has said, but I don't see the element of competition in a trek.
In the USA, then next notch up from treks would be "climbs". So while a trek is physically demanding, it lacks the danger that a climb would have. It would be very rare for someone to die on the trek. Whereas climbing carries the constant threat of death.