The story behind Psalm 139:14
The psalm's heading credits it to David, though many scholars think it took its final form later and dates are debated. It was sung in Israel's worship as a prayer of trust. The psalm moves from God knowing David (vv. 1-6), to God being everywhere (vv. 7-12), to God forming him (vv. 13-16). It ends with David asking God to search his heart (vv. 23-24), so this praise sits inside a prayer of honest self-examination.