You may have missed it - it was only referenced in a couple lines here and there - but the reason he gave the codes to Six is because he thought she worked for a company that was competing for a defense contract. As far as Baltar was concerned, he was just helping Company X beat out Company Y for the contract.
Anyway, I was going to make a big long post about Baltar and why, while guilty of many things, there are other things to consider about his character as well, but actually I think there's a more important point to be made...
This is a TV show. In life, we obviously want to have a stable rule of law and see "bad guys" caught. On the other hand, I propose that in fictional entertainment, it's best to have characters like Baltar who are flawed, make mistakes, but not totally evil. Regardless of whether or not you like Baltar, you have to admit they make an effort not to portray the situation as black and white. Even if you hate him, I don't think anyone would say Baltar is totally evil. Simply put, it makes for good TV. If you want cookie-cutter characters who are either "good" or "bad," and you want to see the "good guys" always prevail and the "bad guys" always lose in the end, watch the original Battlestar Galactica (and I say this as someone who actually enjoyed it, for all its campiness). Otherwise, enjoy the ride, and be
thankful that this Baltar is such a flawed, human character who is not simply evil.