Not an easy question to answer in one sentence!
Seniority is usually the basis on which an individual is selected for command assessment, but with this must come qualification, sufficient relevant experience and suitability. This breaks down quite easily to:
Position on the seniority list as a qualified F/O
The right licence and type rating.
The required number of hours on type, routes and environment as decreed by your company in it's Ops. manual.
Being able to pass a command assessment board that will endeavour to establish that you are mentally ready for command and therefore worth the investment in training, this usually involves an interview and a LOFT exercise in the simulator, not all companies do this final part though.