The number 5 can occur in the hundreds, tens or units digit of an integer in [1,1000], so we do each case:
It's clear only the numbers in [500,599] have the 5 as the hundreds digit, so there are 100 instances of 5 as the hundreds digit.
Every number in the sets [50,59], [150,159], ... [950,959], has 5 as the tens digit, and that's all of them since we've pulled out all the numbers which are between 50 and 59 modulo 100, so there are 10x10=100 instances of 5 as the 10s digit.
Finally 5 occurs as the units digit only in every number congruent to 5 modulo 10, and that's exactly 1/10 of the numbers in [1,1000], so again we have 100 such numbers.
Hence the digit 5 is written 300 times writing all the numbers from 1 to 1000.
There's also probably come to think of it a bijection-y way of doing it, since the equality between the 3 cases hints at some connection - and I think it's just that for any number with a 5 in it, you can permute the digits to get numbers with the 5 in the other digit slots - obviously there's problems with repeated digits messing up some cases but it's probably fine if you deal with a bit of double counting.