One of the ten commandments is “remember to keep holy the sabbath day. Six days you may labor and do all your work, but the seventh day is the sabbath of the Lord, your God. No work may be done then…in six days the Lord made the heavens and the earth, but on the seventh day he rested. That is why the Lord has blessed the sabbath day and made it holy” (Exodus 20:8-10).
The commandment doesn’t say anything about going to church; it simply sets aside one day of the week as a day of rest, when no work was to be done. It became customary among the Jewish people, however, to see the sabbath as a day to be “with” God in a special way. Much of their prayer centered in the home, but they also developed the custom of attending the synagogue on the sabbath to hear and study the word of God. Their sabbath, or seventh day, was on the day we call “Saturday.”
The “Mass” began when early Christians gathered together in their homes to share a meal in memory of Jesus, as he had asked them to do on the night before he died (“The Last Supper”). There was no obligation about this originally–Christians got together to pray, hear the Scriptures read, and share the meal because they wanted to. Over time the meal became more formalized and ritualized, and included readings from Scripture. As more time passed and Christians became more and more distant from the time of Jesus their enthusiasm waned and they no longer gathered for Mass so eagerly. So the church imposed a rule obligating Christians to attend Mass at least on Sunday. Sunday had become the day of worship, rather than the Jewish sabbath, because it was the day when Jesus rose from the dead. The obligation to attend Mass on Sunday is a Church law, not a Divine commandment like the 10 commandments.
You are right that many good people do not attend Church, and many people who are not Christ-like do. One explanation is that going to church is not a badge of merit for good people but a way of receiving God’s love when one truly needs it. Jesus himself said “healthy people don’t need a doctor, sick people do.” Jesus was criticized because he spent most of his time associating with sinners, rather than with the good and respectable people. The Church is doing its job if it becomes a place where sinners can go to receive forgiveness and grace. The good people who don’t go to church are undoubtedly receiving God’s grace by a different “channel” or route. We don’t know what is going on in any person’s heart and we can only judge our own self in how responsive we are to living out God’s invitation to be a faithful, hopeful and loving person.