When a player is all in, it means that he has put all his chips in play. There are many reasons to be all in, but let's name two: to maximize your chances of bluffing and to maximize the payout of your hand. If you think your opponent has an average, but not great, hand and you want him to fold, being all in can convince him to fold. And if, on the other hand, we feel that he has a very strong hand and we have the nuts, we will want to be all in to maximize our winnings.
Psychological aspect of the all in
When a player is all in and is in a casino or any live game, he should announce loud and clear that he is all in. Knowing that you are all in can be interpreted in different ways by your opponents. If a shy player is all in, he will usually have the best possible hand. If he is an aggressive player, he may try to intimidate us with his "all in" to encourage us to fold.