When you are polite and friendly this not only makes things smoother with people who are nice, but it really annoys the jerks who are looking for an excuse to cause you trouble because they don't have one.
A minor story about that: I was coming back from Canada from visiting my parents. I made the mistake of declaring on the customs form that I had meat, which I did, a pack of beef jerky fully sealed, manufactured in the US. So instead of going right through the automated line, I had to go see an agent. This dude had a huge chip on his shoulder. It was pretty clear to me he'd like nothing better than for someone to get annoyed and belligerent with him so he could make their life suck. No such luck here, I smiled, was polite answered the questions and after a bit, was on my way to the next segment.
He'd marked to have my bags searched (at airports in general, and the border especially they can search your bags for any or no reason). So I had to head to the search area. Well I was nice and polite to the agent there who clearly thought this was moronic and gave my bag the most half-assed quick search ever before saying "Thanks you are good to go."
I got to go through with a minimal inconvenience (10 minutes max) and got the satisfaction of him getting to be frustrated with being able to do nothing. I'm not saying it always work, of course, but it works more often than not. Makes your life easier and you get the added satisfaction of making jerks sad.