The Mishnah in Shabbos (146a) states, “A man may break open a barrel in order to take dried figs from it, as long as he does not intend to create a vessel.” Most of the commentators explain that the barrel is of very low quality and intended to be used only once. Since it has almost no intrinsic importance it is considered batel (subservient) to the food inside it. Just as one may destroy a nutshell in order to get the nut inside, so too one may destroy the barrel in order to get the food it contains. In the times of the Mishnah they did not break the barrel such that the figs would be scattered everywhere – in fact, they used to break the top off, and the figs would be within easy reach, so they could be taken whenever needed for the next few days until they were finished. Nevertheless, Chazal added a condition to the mishnah – one may not intend to make a vessel. Thus, if by breaking the top one is making a neat opening and plans to re-use the barrel to store other things, he is performing the melachah of making a vessel – tikkun kli.
Based on this we can surmise that one may open tin cans, boxes and packages that will be thrown out after opening, in order to get the food inside them. Since these items are only intended to be used once and then thrown out, they have no intrinsic importance and are considered like nutshells which are batel to the food inside.
Even if it takes a few days for all the food in a packet or tin can to be eaten, since after the food is finished the container will be thrown out, the container evidently has no importance. Thus, by opening these containers one is transgressing neither boneh kli (building a vessel) nor soser kli (destroying a vessel). However, one who intends to keep other objects in the container may not open it, because by opening it he is thereby enabling its usage. Furthermore, since he plans to use it in the future, there is concern he might make a neat opening, which is in itself prohibited, as the mishnah mentions.
Some opinions prohibit opening tin cans even if one intends to throw them out. Since the tin can is a useable container after it has been opened, one who fashions an opening for a tin can has turned it into a useable kli. In order to try to comply with this strict opinion, some write that is proper to open tin cans before Shabbos. If one needs to open a tin can on Shabbos unexpectedly, some recommend piercing a hole in the underside of the can before opening it, so that when he opens it he is not creating a vessel for it has a hole in the bottom. He should also empty the contents of the can right after opening it.
Notes and Sources
 Shulchan Aruch 314:8
 Shulchan Aruch 314:1
 Rav Shlomo Zalman Auerbach in Shemiras Shabbos 9:3, notes 7 and 10. Minchas Yitzchak 4,82,36. Rav Ovadia Yosef, Halichos Olam 4.
 Igros Moshe Orach Chaim 122:9
 Rav Shlomo Zalman Auerbach, Binyan Shabbos 34
 Making a neat opening is either the melachah of boneh kli (making a vessel) or makeh bepatish (completing a vessel). See Rashi, Shabbos 107b, Shulchan Aruch 314:1, Mishnah Berurah 314:5
 Chazon Ish 51:11. Tehillah LeDavid 314:12 prohibits opening a tin can since one is destroying it (soser).
 Shemiras Shabbos 9:1
 Shemiras Shabbos 9:2