Hi, Leo —
Yes, there is an obligation under pain of grave sin to attend Mass on Sundays and Holy Days.
As for why, you may as well ask the question:
- Why did God provide Adam and Eve with an opportunity to commit a grave sin by telling them not to eat the fruit of the tree of knowledge of good and evil?
Although the answers are different in each case, God made the commandment to test us; to provide an opportunity for us to obey.
As for the Church, I suppose the answer is simpler:
She commands us so to motivate us to do what is beneficial to us. Otherwise people would get lazy and neglect to go to church and not share in the graces that come from the liturgy and the celebration of the Eucharist. Perhaps in a deeper sense, She imposed that obligation to reveal to us the inherent spiritual consequences of neglecting weekly worship: spiritual death, whether or not the Church imposes the obligation.
So in a sense, I don't agree with your question. You say that they only provide the faithful with a further opportunity to commit grave sin.
I reply that they don't provide this, but more importantly, they provide an encouragement and motivation to do what is beneficial to us and avoid what is deleterious.
In other words, the Church does this for our own good. She is not to try to trip us up or make it harder for us to be saved.