Why did James Comey get fired?

President trump went to twitter today to defend his decision to fire FBI Director James Comey, tweeting that democrats had complained about Comey for months.