In A Study in Scarlet, Dr. Watson meets Stamford—an old medical school acquaintance—by chance in London. Stamford, knowing Holmes is looking for a flatmate, introduces Watson to Holmes, describing him as a "remarkable man" with eccentric habits. Holmes and Watson then agree to share rooms at 221B Baker Street.
Crucial detail: Holmes does not know Stamford beforehand. Stamford knows Holmes (from St. Bart's chemistry lab) and acts as the matchmaker. Without Stamford, the greatest partnership in detective fiction never forms.