I wrote this in response to someone who thought that "keeping rules" was a trite replacement for "having a relationship with God".
A real relationship with God comes from keeping his commandments, because that is the only path that leads us to know him through the gift of the Holy Ghost.
In fact, Christ taught that the way he, Christ, measures our love for him is by how we keep his commandments.
"He that hath my commandments and keepeth them, he it is the loveth me".
There you have it, Christ's own statement of how he measures our love for him. It is by how we keep his commandments.
Not surprisingly, Christ attributed the depth to which is Father was with him to the fact that he always obeyed his Father. Christ said:
John 8:29 "And he that sent me is with me: the Father hath not left me alone; for I do always those things that please him."
Of course, anyone who thinks obedience to commandments is trite ought to consider Christ's own words on the matter. In addition to the above, maybe consider his words "For how knoweth a man the master than he hath not served". We also get interesting insight from 2 Nephi 31:10 "And he said unto the children of men: Follow thou me. Wherefore, my beloved brethren, can we follow Jesus save we shall be willing to keep the commandments of the Father?"
Once again, Christ himself states that our love for him is measured by how we keep his commandments. Those that do are those that he says love him.
And Christ further points out the tie between a real relationship with God and keeping his commandments in John 14:23 "Jesus answered and said unto him, If a man love me, he will keep my words: and my Father will love him, and we will come unto him, and make our abode with him."
So if we really love him, we obey commandments. And if we obey commandments, he feels that we really love him. And if we do that, then He will love us, and his Father will, and will come and make their abode with us. If what we have hoped for is a personal relationship with Christ there is no more we could have hoped for in a personal relationship with Christ than the message in John 14:23 because:
D&C 130:3 John 14:23—The appearing of the Father and the Son, in that verse, is a personal appearance; and the idea that the Father and the Son dwell in a man’s heart is an old sectarian notion, and is false.