Chapter seven starts from an observation about duration. Heaven lasts and earth endures, and the reason given is that they do not live for themselves; not living for themselves, they are able to last.
The move from that to human conduct is immediate. The sage puts himself last and finds himself in front, treats his own person as external and finds it preserved. The chapter then asks its own question: is it not because he has no private ends that his ends are accomplished?
This is one of the passages that makes readers uncomfortable, and the discomfort is worth naming rather than smoothing over. The chapter appears to recommend selflessness on the grounds that it works out better for the self, which is either a paradox with something in it or a piece of advice that cancels itself. If a person puts themselves last in order to end up first, they have not put themselves last.
The book does not resolve this and does not seem to notice it as a problem, which is itself informative about what kind of text it is. It is not building an ethical system in which motives have to be consistent. It is stating, repeatedly and from many angles, that the direct pursuit of an outcome tends to prevent it, and leaving the reader to work out what to do with a piece of knowledge that changes if you act on it deliberately.