The difference is slightly fluid, but generally a teacher refers to a qualified person working under an academic organisation such as a school or college, typically teaching groups of students (classes). The word might also be used for someone doing the same kind of worn on a private 1 to 1 basis, but the word tutor is more specifically used in that case.
An instructor tends to be someone who trains someone in a practical skill, often with the goal of achieving a certain standard, perhaps necessary for a career - a driving instructor, a ski instructor, a diving instructor etc.
Trainer can be used for someone giving semi-informal classes on a vocational subject, perhaps practical computer skills for example, but is more often used to mean someone who guides in sporting or athletic activities - gym trainer, football trainer, fitness trainer etc.
Hope that's useful :)