The cause of this is that our eyes see selectively, but the camera lens does not. The camera sees everything in its field of view. When we are looking at our subject, the background is not evident to our eyes unless we train ourselves to look at it. Take time to look up, down, left, right, behind your subject as you look through the camera's viewfinder. Candid photos usually look more natural.
People are more natural if they are doing something rather than just posing.
You will rarely regret getting closer, you will often regret NOT getting closer. For instance, if they are talking but they are not close to each other, just ask them to continue talking, but move closer together. Pictures of buildings, etc. are more interesting if there are people in the picture. Making group photos interesting has been a challenge for photographers ever since the start of photography. If you don't have a choice to place your subject somewhere else, at least change your own position so you are not facing the window straight on.