It depends on what the problem is, but it is a risk you take as a buyer to buy a new in package item.
Mainly the problem is going to come from old, corroded batteries. Don’t pull the tab on old batteries. Unscrew the back and replace the batteries first. If it has LR44 batteries there may be corrosion, but not always. CR2023 seem less likely to corrode. AA and AAA will definitely be corroded if they came preinstalled, though usually these batteries are not included.
If there is corrosion you can clean the contacts with a dry cotton swab for chunky bits, ultra fine sand paper (or what I do is cut the striker off a matchbook and sand with that), the pointy tip of a safety pin can clean odd places, and with a cotton swab dipped in isopropyl alcohol for a final cleanup. Sometimes the corrosion is too bad to clean up completely, but often times the device will still work after a good cleaning.
With Tamagotchi products I have had good luck. Either the batteries had not corroded, or it was very light corrosion and easy to clean. Other brands I have seen pretty bad corrosion from LR44 batteries. Especially with GigaPets Explorer Minipets. Those you can easily take apart and replace most of the contacts with an extra Minipet you are willing to sacrifice.
Either you take the risk or buy one that has been opened. I prefer open ones since they are usually cheaper and I open them anyway. If it is an open one I request a photo of the battery compartment from the seller if there isn’t one in the listing, and I also ask if there is any corrosion in the compartment. If they can’t provide it or at least answer me, then I don’t buy it. Usually the sellers are quick to reply with a photo (on eBay).
I have purchased a few “not guaranteed to work” from Japan You Want and they were in great working condition. Again it is a risk I took. Not everyone is so lucky. Don’t spend the $$ if you would regret it not working. For me the price was good on those couple of items, so I risked it. Otherwise go for one that is open and confirmed to work.