Timothy was of Lystra (Acts 16.1-2), being the son of a Greek father and Jewish mother; his grandmother was also Jewish; these had taught well the Holy Scriptures (the Old Testament) to Timothy since his childhood (2 Timothy 1:5; 3:15).
It seems that Timothy was converted by Paul on the occasion of the first visit of the apostle to Lystra (Acts 14:6) and, sometime later, Paul called him to be his companion in missionary work. He was with the apostle in Troas, Philippi, Thessalonica and Berea and, on the third journey, accompanied him for part of the way to Jerusalem (Acts 20:4). Later, he was in Ephesus, where Paul called him to go to Rome (2 Timothy 4:9-21), where the apostle was expecting the death sentence. It is not known whether Timothy arrived there before the martyrdom of the apostle.
Note that Paul attributes his authority as an apostle to both the Father and the Son - it is by mandate of "God our Saviour” and of "Lord Jesus Christ, our hope", which are also our "Father" and our “Lord”.
Timothy is the “true son in the faith" of Paul, having been converted by the preaching (and maybe the suffering) of the apostle (see Acts 14:19) and Paul understood the difficulties that the young man would find in Ephesus. Therefore, he wants that he may have not only the grace and peace of God but also his "mercy" (v. 2) - repeated in the salutation of the second letter. It is only in these two letters that Paul includes "mercy" in the salutation. The epistle of Jude has a similar greeting.
Note that the Apostle "urged" and did not "order" Timothy to stay in Ephesus. The task would be difficult and Paul did not want to force his young disciple to accept it; however, to Timothy the smallest desire of his "father in the faith" was as the Lord's commandment.
The task of Timothy at Ephesus, then, was to admonish certain people with regard to the doctrine they were teaching (v. 3), also to warn them not to waste the time of the church with discussions about matters of no importance or usefulness in evangelical service (v. 4).
About the doctrine, let us remember that Paul, in his journey to Jerusalem, had already warned the elders of the church in Ephesus that ravenous wolves would penetrate which would not spare the flock, and that, within themselves (the Ephesians) men would arise speaking perverse things to draw the believers after them (Acts 20:17,29,30). It seems that this was already happening.
The reason for "this commandment" (that is, through this letter), was to produce between Christians the love which is the fruit of a pure heart, conscience and sincere faith in their own masters. Unfortunately, some among these, not having these qualities, turned to talking only nonsense, but wanted to be considered "masters of the Law", equal to Gamaliel and other eminent teachers (see Acts 5:34 and Luke 5:17).
The main reason for the Divine Law, given in the first books of the Old Testament and summarized in Luke 10:28, is to reveal to people how terrible is sin, that they repent and receive the forgiveness and salvation that the Gospel offers. Being justified before God by faith in Christ, the Christian can use the law to understand the will of God, which he will obey in the Power of the Holy Spirit.
However, what a list we have here of various types of sinners! Fourteen are mentioned specifically and then there is a general condemnation of “all that is opposed to sound doctrine". We cannot deny that all these kinds of sin are becoming increasingly common in current society. Those who practice such things are condemned by the Divine Law, are in danger of eternal damnation, but "the glorious Gospel of the blessed God" offers them salvation through the Lord Jesus. Such is the "sound doctrine" that should occupy Christian teachers and that was "once and for all delivered to the saints" (Epistle of Jude, v. 3).
1 Paul, an apostle of Jesus Christ, by the commandment of God our Savior and the Lord Jesus Christ, our hope,
2 To Timothy, a true son in the faith: Grace, mercy, and peace from God our Father and Jesus Christ our Lord.
3 As I urged you when I went into Macedonia—remain in Ephesus that you may charge some that they teach no other doctrine,
4 nor give heed to fables and endless genealogies, which cause disputes rather than godly edification which is in faith.
5 Now the purpose of the commandment is love from a pure heart, from a good conscience, and from sincere faith,
6 from which some, having strayed, have turned aside to idle talk,
7 desiring to be teachers of the law, understanding neither what they say nor the things which they affirm.
8 But we know that the law is good if one uses it lawfully, 9 knowing this: that the law is not made for a righteous person, but for the lawless and insubordinate, for the ungodly and for sinners, for the unholy and profane, for murderers of fathers and murderers of mothers, for manslayers, 10 for fornicators, for sodomites, for kidnappers, for liars, for perjurers, and if there is any other thing that is contrary to sound doctrine, 11 according to the glorious gospel of the blessed God which was committed to my trust.
1 Timothy chapter 1, verses 1 to 11