While a villager is sleeping in a bed, if you stand on the bed, the villager can be pushed and will begin to float. While floating in this way the villager will pass through blocks. The way you're standing on the bed determines the direction in which the villager will be pushed. Thankfully, this does not seem to harm the villager. They don't take damage from suffocation, if you try to punch where they're floating nothing happens, and zombies don't notice them. When morning comes or if you sleep in the bed, the villager will exit the bed in the normal location.
Related issues
Comments

Thank you for your report!
We're actually already tracking this issue at MCPE-101202, so I will resolve and link this ticket as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki