Dr. John Frame, in his excellent volume, The Doctrine of the Christian Life (Theology of Lordship series), explains below what goes into to making a "good work" before God. (Relatively and humanly speaking, people may do good works toward one another, but the question here is, what is a good work before God, what kind of work is he is pleased with?) He answers...
"Note the three necessary ingredients: (1) a heart purified by faith, (2) obedience to God’s Word, and (3) the right end, the glory of God.
"The first is a plainly biblical emphasis. The Westminster Confession cites Hebrews 11:4 and some other texts. Romans 14:23 also comes to mind, which says, 'For whatever does not proceed from faith is sin.' In Jesus’ arguments with the Pharisees, too, it is evident that our righteousness must not be merely external (see especially Matt. 23:25–26). In describing the necessity of an internal motive for good works, Scripture refers not only to faith, but especially to love, as in 1 Corinthians 13:1–3 and many other passages. We learn from these passages that love is not only necessary for good works, but also sufficient; that is, if our act is motivated by a true love of God and neighbor, we have fulfilled the law (Matt. 22:40; Rom. 13:8; Gal. 5:14).
"The second element of good works, according to the Confession, is obedience to God’s Word, to his law. Note the references in the previous section to the importance of obeying God’s Word. Certainly obedience to God’s Word is a necessary condition of good works, for disobedience to God’s law is the very definition of sin (1 John 3:4). It is also a sufficient condition, for if we have obeyed God perfectly, we have done everything necessary to be good in his sight. Of course, among God’s commands are his commands to love (see the above paragraph) and to seek his glory (see the next paragraph).
"The third element is the right end, the glory of God. Ethical literature has often discussed the summum bonum, or highest good, for human beings. What is it that we are trying to achieve in our ethical actions? Many secular writers have said this goal is pleasure or human happiness. But Scripture says that in everything we do we should be seeking the glory of God (1 Cor. 10:31). Any act must glorify God if it is to be good, so seeking God’s glory is a necessary condition of good works. And if an act does glorify God, then it is good; thus, glorifying God is a sufficient condition of good works.
"So there are three necessary and sufficient conditions of good works: right motive, right standard, and right goal. Right motive corresponds to the lordship attribute of covenant presence, for it is God’s Spirit dwelling in us who places faith and love in our hearts. Right standard corresponds to God’s lordship attribute of authority. And right goal corresponds to the lordship attribute of control, for it is God’s creation and providence that determine what acts will and will not lead to God’s glory. God determines the consequences of our actions, and he determines which actions lead to our summum bonum."