The object of Chess is to checkmate the other player, to avoid being checkmated, or to achieve a draw if that is the best thing given the circumstances.
A chess program selects moves via use of a search function.
http://web.archive.org/web/20120421170110/http://chessprogramming.wikispaces.com/Alpha-Beta
http://web.archive.org/web/20120209041607/http://chessprogramming.wikispaces.com/Minimax
http://web.archive.org/web/20120209042116/http://chessprogramming.wikispaces.com/Negamax
http://web.archive.org/web/20120427185347/http://chessprogramming.wikispaces.com/Quiescence+Search