While it is uncommon to lose data during a battery replacement, there is always a chance. The battery replacement itself will not cause any data loss, but if something were to go wrong, it could wipe the iPhone. This is very likely if you try to replace your battery yourself.