Lofven's resignation comes a week after he became the first Swedish leader to lose a vote of confidence.