The usual reason for an upgrade is due to overbooking economy class, for revenue management reasons, for equipment swaps, etc.
Airlines generally do not upgrade people when seats are available in the class they paid for, because that costs them money.
Usually upgrades are prioritized by status and fare class. So your *S status could have played a role. That said, what procedure is supposed to be and what actually happen can be very different, so there is definately a large luck component.