First, while you can't see the PHP, you can see all the (X)HTML and CSS which can give you a pretty good idea for how well coded the theme is. Additionally, some places let you download and use the theme, only paying for support (such as Theme Hybrid). Lastly, you can tell based on reputation or other projects. For example, I know that Studio Press has quality code in their themes because programmers that I know have said so. Additionally, I know that Joost has been inside their themes to work on the code and I know he produces solid code (because I've seen it elsewhere such as his plugins).