The leading dot hides the file from some directory listings. This comes from historical behavior of the ls command, which lead many programs to use leading dots to denote files that aren't meant to be visible in directory listings, which in turn lead to many file managers hiding such files by default.
The tilde is an unusual character in file names, so there's not much risk of colliding the file name chosen by the user. Why a tilde? Tildes are especially unusual at the beginning of file names, because a leading ~ means “home directory” in shells and many other programs. So prepending a tilde is unlikely to cause a collision. A possible additional factor because when it's at the end of a file name, it's a traditional way to name backups, so adding a tilde to a file's name has a flavor of “some file that is related to this other file, but is not the one the user usually wants” (but it couldn't be at the end because that's already taken). The tilde may additionally have been inspired by the lock files used by Microsoft Office, which start with ~$.
The hash at the end ensures that the file doesn't have an extension that other programs would recognize. If the file was called .~lock.MyDocument.odt, file managers would offer to open it in LibreOffice. Why a hash rather than some other character? Hash has a small tradition of being used in lock file names, for example Emacs uses .# followed by the name of the file that's being edited.