First and Second Timothy, plus Titus, are referred to as the "Pastoral Epistles". Timothy was one of Paul’s closest disciples from when Paul first recrutied him.
Around the time that this epistle was written, Paul had just been released from his first imprisonment in Rome, and he was revisiting several of the cities where he had preached before, including Ephesus.
Upon his departure from Ephesus, he asks Timothy to stay behind as his personal representative to the church there. By the time that Paul arrives in Macedonia, Timothy finds himself serving as the pastor of the church at Ephesus.
Before his planned return to Ephesus, Paul writes this letter to Timothy, to provide him preactical advice for his pastoral ministry there.
It is believed that this letter was written around 64 AD while Paul was in the Macedonia/Philippi region.
By way of background, Timothy was a native of Lystra. His mother, Eunice, was Jewish and his father was Greek. He and Luke were Paul’s two most constant companions, and Paul loved him like a brother and was lonesome without him.
Tradition states that he continued to care for the church at Ephesus after Paul’s death, and that he was ultimately martyred under the Roman Emperor Domitian or Nerva.