Then the Lord said to Cain, "Why are you angry? And why has your countenance fallen? If you do well, will not your countenance be lifted up? And if you do not do well, sin is crouching at the door; and its desire is for you, but you must master it." (Genesis 4:6, 7)
Cain and Able both brought their offerings to the Lord. Abel brought an animal sacrifice and Cain brought a grain offering. The Lord accepted Abel and his offering; But for Cain and his offering He had no regard. So Cain became very angry and his countenance fell. (Genesis 4:5) The reason that the Lord didn't accept Cain or his offering is because Cain wanted to worship the Lord his way rather than in obedience to the Lord.
Cain's sinful rebellion and unrighteousness continued. His refusal to worship the Lord in the acceptable way lead to more sin, even the killing of his righteous brother Abel. It wasn't that Cain didn't know the Lord or what was acceptable worship. No, Cain just wanted to have it his way and to worship the Lord according to his own, self-determined religion.
Not much has changed since the days of Cain and Abel. Most religious people still refuse to submit to or come to God in what is the only true and acceptable way; Jesus said to him, "I am the way, and the truth, and the life; no one comes to the Father but through Me." (John 14:6)
Any religion, no matter how sincere or popular, that teaches that you can somehow worship God and be accepted by Him apart from faith alone in the Lord Jesus Christ and His Gospel, is a false religion; God is spirit, and those who worship Him must worship in spirit and truth. (John 4:24) Jesus is the truth, the object and the cause of our true and acceptable worship. Maranatha!