The Exile served with Revan during the Mandolorian Wars, when the Wars end, Revan takes the Republic Fleet in his followers to the Unknown Regions(The First Time) seeking out the Star Forge. HK-47 Wants the Exile killed but Revan lets him go. Then Revan comes back with the Fleet which is "new and improved" and he wages a war against the Republic, during all this the Exile goes back to Coruscant and faces exile by the Council. Thus during the wars the Exile drifts from planet to planet. Revan at the time get's boarded and get's betrayed by Malak and the Jedi "rescue" him. He gets his memory wiped and the memory given to him is of a soldier, and then you have the events of KotOR 1, then after the game, Revan seems to get his memory back and departs for the Unknown Regions(The Second Time) once again to face the "True Sith". Then a few years after you have KotOR 2 and the Exile, then after that game he departs for the Unknown Regions seeking Revan. That's the games in a nutshell.
Also the HK-50s and 51s are based off of HK-47s design, they were programed by GOTO to hunt for the Jedi Exile and kill him, or something along those lines...