Hypothesis 1: a player gets substituted when their "instant" rating (by instant rating I mean the rating they would have if they played just a few minutes) falls below the one that would be offered by the next player on depth chart.
I think this is more or less what happens. I assume that, for each position, there is some weighting of a player's skills that is taken into account. Multiply this by some factor to account for form, and then decrease it some percentage based on the amount of energy the player has. When this dips below the substitute's value, then the substitution should be made.
And to account for the fact that the game might wait a bit to replace a crappy starter with a good sub, they might have it set up so that starters get a bit of a boost to the weighting of their skills (for determining subs, not for game performance).
I think this seems quite reasonable. Of course, I wouldn't be surprised if they did things completely differently! :)