I first heard this idea from an MMA fighter. He said you need someone who’s better than you (+1), the same as you (0), and worse than you (-1). The better fighter shows you what is possible, how much better you can be. The gym rival, the one who’s the same, is there to compete with. You’re constantly pushing each other to get better. The person below you is someone to teach and to guide. You get better by helping them.
The same is true for the gym. Folks who are stronger show you what you’re capable of. If you walk in and see everyone deadlifting 225 or more, you probably won’t think much of seeing the weight on the bar. If you never see someone lift that, you might think 225 is unattainable or scary.
Having a training partner who is near your strength is a good thing. You push each other, especially if you factor in your strengths and weakness. I had an old training partner who had a massive squat. Watching him squat made me better as it gave me something to chase. His bench wasn’t as good, and so not only did that give him something to go after, it made me want to keep my “lead.”
Finally, having someone there who’s not as strong as you is good. As the adage goes, when 1 teaches, 2 learn. Moreover, as that person gets stronger, it’ll motivate you to keep improving.