Valid means that the essential elements of a sacrament were present and thus the sacrament took place.
Illicit means that the ritual was not properly performed according to the liturgical norms but the sacrament took place.
Assuming there’s a validly ordained priest with faculties and the proper matter of bread and wine, the only way that a Mass could be invalid is if the words are consecration were so greatly changed as to change the plain meaning of the words. Even a small change in the world (e.g. a priest says for all instead of* for many*) would not invalidate the Eucharist since the essential meaning is the same. Generally speaking if a priest were to substitute poems for the Scripture readings, it would be greatly illicit (and sinful) but as long as the words of consecration were correct (or only slightly changed) then the sacrament would still be valid.
Attending a Mass where the celebrant illicitly introduces elements contrary to the ritual, it still fulfills the Sunday obligation of the faithful. They attended Mass and worshiped the Real Presence of Christ, it’s not their fault the celebrant made illicit choices within the Mass. However, if the Mass was invalid then the obligation to attend Mass would not be fulfilled since there was no actual Mass (no valid consecration, no Real Presence).