Yes that's the problem with digital. Will it be possible to read jpegs, tiffs and raws in 40 years?
TIFF and JPG will certainly be readable for an extremely long time. I'm also now sure that support for most RAW formats will be available too.There is a critical mass of these files now that makes support inevitable. Whilst the data is regularly archived from media to media, it's possible to keep it accesible. I'm sure many of us have some old data that would have started once on a floppy and has been repeatedly transferred and is still accessible on contemporary media.
Look back at format support in document files and it's pretty universal.
If a Betamax video surfaces now can it be viewed anymore?
Yes, at the moment, but that's a different proposition.
Magnetic media is in a continuous slow state of decay, is difficult to copy and is reliant on it's mechanical construction to be playable. Then you have to have mechanical playback machines that have a limited life, playback heads simply wear out after enough tape has passed over them and there's few spare parts now.
It's already got to the point that there's more recorded 1" video material in storage in the UK than there is head life of the machines to play them back.