Brilliant film.
Essentially due to Leonard’s condition he makes the perfect killer – he is set on revenge and can’t remember his previous actions.
Teddy is a dirty cop who wants a drug dealer Jimmy killed and uses Leonard as the killer by convincing him that he killed his wife.
Teddy then fills in Leonard with the facts that they found and killed his wifes killer months ago and he has been using him all this time.
In the final scene of the film (which is actually right in the middle chronologically) Leonard realises that Teddy’s knowledge is potentially dangerous to his mental construct so sets himself up to kill him by writing down his number plate