~ is a “aliás” to your user home directory. If you are anywhere and want to copy something into your documents folder you can do cp file.txt ~/Documents instead of cp file.txt /home/username/Documents
So by typing rm ~ it actually deleted the /home/username directory instead of the ~ file in it.