David was a leader who wanted God in all the areas of his life including having integrity when he was alone in his home.
This Psalm is an interesting comparison to Psalm 51 in which David cried out to God to forgive his sin he had committed with Bathsheba.
I will sing of your love and justice, Lord.
I will praise you with songs.
2 I will be careful to live a blameless life—
when will you come to help me?
I will lead a life of integrity
in my own home.
3 I will refuse to look at
anything vile and vulgar.
I hate all who deal crookedly;
I will have nothing to do with them.
4 I will reject perverse ideas
and stay away from every evil.
5 I will not tolerate people who slander their neighbors.
I will not endure conceit and pride.
6 I will search for faithful people
to be my companions.
Only those who are above reproach
will be allowed to serve me.
7 I will not allow deceivers to serve in my house,
and liars will not stay in my presence.
8 My daily task will be to ferret out the wicked
and free the city of the Lord from their grip.