There are several ways in which this term is used.
First, and most simply, it is the direction on the stage away from the audience. Stages are often slightly sloped down, or "raked" toward the audience, so that the actors further away from the audience are elevated; so this term makes sense.
Second, it refers to the relative placement of two actors on the stage. If one is standing slightly upstage of the other, he will have an advantage because his body is naturally more open to the audience while the downstage actor will have to turn away from them. The first actor is said to be "upstaging" the second, sometimes with subtle, malicious intent!
Third, it refers to deliberately distracting activity by one actor behind the back of another, competing for surreptitious laughs. The first actor is said to be "upstaging" the second with obvious malicious intent! But the delinquent actor is not to be blamed for having a sense of fun. This, and similar monkey business, are symptomatic of a production in which the director did not know how to engage the dormant energies of the actors.
Fourth, it refers to anything onstage, or even off, where somebody or something, often quite innocently, steals focus from the intended centre of interest. A stray cat wandering across the stage will upstage the actors. A beautiful, glamorous guest at a wedding, wearing a fantastic gown, upstages the poor homely bride.