There must be some probability distribution of how likely a value of $X is to appear in the envelope with the smaller amount of money and how likely it is to appear in the envelope with the larger amount of money. Since we're dealing with real numbers instead of integers, we should really deal with ranges of values instead of single values, and talk in terms of the probability that the money in an envelope is between any two values $X and $X+Y.

If we have absolutely no prior knowledge of how much money is in each envelope, I could propose that there is an equal chance of finding any value in the smaller envelope. (This should also work if the upper limit of how much money is in the envelopes is large compared to the value that you find.) That is, for any X and Z, the probability that the smaller envelope contains a value from $X to $X+Y is equal to the probability that it contains a value from $Z to $Z+Y. Let the probability that the smaller envelope contains a value from $X to $X+Y or from $Z to $Z+Y be denoted P(S,Y).

Now, what is the probability that the envelope with the larger amount of money contains a value over the range $X to $X+Y – denoted P(L,Y)? It must be exactly the same as the probability that the envelope with the smaller amount of money contains a value over the range $X/2 to $(X+Y)/2, which is equivalent to a range $Z to $Z+(Y/2), or P(S,(Y/2)). That would be equal to one half of P(S,Y).

That proves that P(L,Y) = P(S,Y) / 2. So if you are shown any arbitrary amount of money in the envelope, you will know that you are twice as likely to have the smaller envelope as you are to have the larger envelope. You should most definitely switch.