How do we know that reality is still there if no one is there to observe it?
The idea that the world goes away when we aren’t looking is commonly called Subjective idealism or Empirical idealism. (I.e. your mind forms subjective ideas about reality which then appear to you as matter. If your mind isn’t there, maybe the matter won’t be there either.)
If we take the idea of Subjective idealism to mean that we cannot know anything about the objective world, then Kant encroached a great deal on this problem by taking a step back and saying that we can know some things to be absolutely true no matter what (e.g. a triangle has three sides). So even if our experience of the world is totally screwed up, the concepts will still be right.
Kant then suggested that you can start from certain concepts (triangles have three sides) and then extend that certitude to fields like math. (You don’t know that 2+2 = 4 like you know that a triangle has three sides, but once you have tested 2+2 it’s always = 4.) This then forms a synthesis of ideal and actual knowledge that never fails for anyone. So we can also know that with certainty.
People coming after Kant then went even further and said that in the same way that 2+2 is always = 4, we can move even further out of our heads and into the world. Every time somebody analyses water it turns out that it is H2O and never anything else.
In this way we can start with pure conceptual knowledge in our heads (triangles have three sides) and then creep further and further out into reality. That the empirical world appears with regularity and appears to have a consistency no matter who is observing it is a huge deal in favor of empirical reality being objective and hence in some sense actually there. Confronted with this argument, the opponents of the 1700s could only intervene to say that the source of this objectivity was God who made a “consensus reality” for all observers. Even back then it was obvious that this was a bullshit argument.
So even though we cannot 100% refute that reality goes away when we are not looking, we can get very far towards proving that it doesn’t go away. (Certainly we can do way better than those who say reality is subjective.) This does not mean that we get to experience all of reality entirely as it exists on its own terms (we don’t), but it means that we get to experience a good deal of reality with a regularity that is shared by all subjects and which appears to be internally consistent. Empirical reality cannot reasonably be said to be subjectively created by our minds although it could be said to be interpreted by our minds, i.e. warped to fit with the mind’s nascent need to see things as structured in space, time, quantity, etc. – categories which would not necessarily be there if there was no observer.
Thus, if a tree falls in the forest and no one hears it, it is overwhelmingly likely that it will make a sound, though with no observer present to cognitively structure the experience, there may well be no tree, nor sound to be discerned as entities standing apart from the rest of the totality of reality.