He explains why in the next verse. The things that cause you to sin, or at least attempt to cause you to sin, is testing your faith. Every single time you mess up or almost mess up, those are times that your faith is being pushed at. It is okay though, it isn't for nothing. Every mistake and temptation helps create in you patience.
Patience can be defined as putting up with people trying to provoke you, dealing with annoying people or circumstances, getting through misfortune, dealing with delays, hardships, and delays, and so much more with a calm heart as well as not saying anything that could come across as complaining.
Complaining is a tricky thing. You wouldn't believe how easy it is to complain. Or maybe you do or am starting to with it being mentioned here. Complaining can take several forms. Commonly it is spoken in an obvious manner. However it can also be seen in our actions and how we we treat items and people around us. Being rude or giving someone the cold shoulder. Slamming that pan or plate down instead of setting it down as you normally would. Walking so that your feet hit the ground harder than normal. These are all forms of complaining. The most elusive form of complaining though is playing the martyr. Saying something in what appears as a positive form, but brings for sympathy from others because it still focuses on your misfortune or assumed slight instead of focusing on God's love in your life.
Verse 4 explains how having patience helps your life. I have to admit, when I read verse 4 I was stumped. Thankfully, God leads. To the best of my current understanding of this text, patience leads to a person being mature in their faith and relationship with God. If you have God as a close friend, you need nothing else. He will take care of you.