People commit crimes because they have to. I'm mostly referring to the less sociopathic criminals like robberies or drug dealing. I used to be heavily involved with the prison health system (it was a job I wanted, would you believe) and got to meet a lot of prisoners of all different types. For the most part, every single one of them weighed the risks before commiting the crime and they knew their luck - but they had to do it. You'd probably say, "Nobody HAS to." but when you're faced with a situation where the very other likely option to prison is death (can't feed your family, government won't help, can't get a job, wife got pregnant, baby is crying) you do what it is you feel you have to do to protect yourself and the ones you love. The majority of crimes (or at least, imprisonable ones) I'd have to say are not committed just for the fun and dalliance of it (though this occurs, clearly).
I actually have quite a soft heart for criminals, especially ones making a clear reformation effort who are just getting spit on by the system for something even they admit was a mistake they made out of sheer desperation to protect their family. I know I am not one of many and a lot of people would rather see those in the prison systems just die or rot, but you actually have to look at it from there side just for a moment. Nobody actually says "but I won't get caught!" they have a very real knowledge they might - and with that risk there's probably a very VERY good reason they chose to commit the crime. You don't risk that much for no reason. Not saying the reason is -valid- or -right-... but saying there usually is one, moreso than just being 'stupid' or 'naive'. It might've meant, to them, the difference between a roof and homelessness. If they go to prison, they still get food - so either way, food will come in. Somehow.
Although I think you might be referring specifically to murder. There's a broad spectrum of crime though, so I went with milder forms.