Where does the new tile appear in Threes?

It is random, but based on the direction you swipe and which spaces are empty.

So, if you swipe toward the right wall, the card will fill in an empty space on the left wall and if you swipe up, it will fill in from the bottom. If you have move to make, the move will always create at least one blank spot. The fewer open spots you have on the edge the tile will fill in from, the more likely it will be that it will end up in the space you just created with a match, so sometimes it feels like there's a pattern to it.

I wasn't able to find a definitive answer - the open source game that was inspired by Threes, 2048, has slightly different mechanics, so looking at the code there doesn't help. After playing for a while and paying attention to where the tiles come in, if the placement isn't random, the pattern is very complex and that seems out of character for a game with such simple mechanics. At first I thought it might be random across columns or rows where you had made a match, but that's not the case.