The Note of the Apostolic penitentiary on the importance of the internal forum and the inviolability of the sacramental seal, quoting an address of Pope Francis, suggests two reasons for the existence and inviolability of the sacramental seal: the sanctity of the sacrament, and the freedom of the conscience of the penitent, who must be sure that what he reveals to God through the mediation of the priest will remain between him and God.
The "sanctity of the sacrament" is found in the seal, in that priests in the sacrament act “in persona Christi capitis”, that is, in the very person of Christ the Head. In confessing his or her sins to the priest, who represents for him or her Christ, with whom he or she comes into contact in the sacrament, the penitent bears witness to the saving mystery of Christ and the supernatural character of the Church and ministerial priesthood. Conversely, the seal binding the priest is a form of testimony to that same saving mystery of Christ present in his Church.
On this account, what directly and properly falls under the sacramental seal of confession is that which is submitted, through the priest, to the saving power of Christ: the penitent's sins (real or supposed). Other things mentioned during confession fall under the seal indirectly, if and to the extent that through them the sins could be inferred or suspected. This is also St. Thomas Aquinas's account, and seems to be indicated by canon law. A penitent's mentioning, e.g., that he went to McDonald's the other day could fall under the seal to the extent that a sin of gluttony, disobedience, imprudence or the like might be inferred. In principle penitents (especially persons inclined to rambling) may mention things in confession that are entirely accidental to the confession and bear not the slightest suggestion of a sin. These would not fall under the seal as such, but in practice priests will often treat these as falling indirectly under the seal in order to be on the safe side of upholding the seal of confession — if they were to exercise liberty to remember and to mention such things, they might easily make a mistake in judging something to be wholly accidental to confession.
Moreover, canon law forbids uses knowledge acquired from confession when it might harm the penitent, even if all danger of revelation is excluded, and thus not contrary to the seal of confession. This canonical prohibition helps to ensure penitents' confidence in going to confession, in that they can be confident not only that the confession will not be revealed, but also that no indirect disadvantage will come to them from anything they say in confession. Here, too, a priest could easily make a mistake about what might harm the penitent, and so it is safer to make no use at all of knowledge acquired from confession.