Introduction
A telescope creates the illusion of objects in the sky appearing closer than they actually are. This is created by focusing it at infinity and therefore enhancing the size of the image created by the eyes. If the telescope is not focussed at infinity, the image of the target becomes blurry. But to better comprehend how this works, some background is needed.
Infinity Focusing
For all practical purposes, focusing at infinity simply indicates focusing on something far, far away. In optics, infinity focus is the state where a lens creates an image of a target located an infinite distance. Focusing your lens to infinity focuses all the objects in your frame, no matter the distance.
Think of it this way: infinity focus is comparable to an exceptionally wide depth of field. Having a lens focused at infinity, again, means that everything you observe will be in focus no matter how far away it is from the lens.
Focusing a Telescope
The purpose of a telescope is to observe targets at infinity and to make the produced image appear to be at infinity. When looking through a telescope, the eyes adapt and adjust their focus as if the target is far away. The telescope's job is to make objects seem closer by enhancing the angle of the ray bundles one sees. We also refer to this by the name angular magnification.

Source: Griffithobservatory.org
A telescope is focused by using the eyepieces. By altering their position, the focus is changed in a way that blurry celestial objects become sharp. The focus is most often improved by turning a small knob, but all telescopes are built slightly differently. After finding the focus control, point your telescope at an object far away and adjust it until you get a sharp image.
Conclusion
The story behind telescope focusing is simple, and to answer your question, the telescope must be focused at infinity so the observer sees an enlarged image of a distant object. Having a basic understanding of how this works will help you to get the most out of your equipment as an observer.

