When setting your spawn under ground by sleeping in a bed, you will spawn back on the surface after dying.
This happens even if your bed has air to all sides of it, and even in a 3+ tall room.
How to reproduce:
1. Hollow out a little room under ground, make sure there is room to all sides and above the bed as well.
2. Sleep in the bed, and allow it to kick you out after you have slept.
3. Die, and you will respawn on the surface.
From what i can tell, this bug is also related to: https://bugs.mojang.com/browse/MCPE-42881
Footage of this bug happening and how to reproduce. Skip to 7:24
https://www.youtube.com/watch?v=9AgSEVfJicE
Linked issues
Comments

Thank you for your report!
We're actually already tracking this issue at MCPE-39261, so we 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.