When david was being lazy and not doing the things he should do, like going to battle, he had time to think about nonsense stuff and thus sin. We should always guard our hearts against laziness as well, which might cause us to sin.

2 Samuel 11:1