It has to do with density. Guinness is a lower gravity than Bass and will float on top. The clear divide is the tough part, but that's why you usually see it poured over the back of a spoon (or something similar). If you pour too hard, then the Guinness will start to mix with the Bass, and you see less of a sharp split between the two.
This is the same way that layered shots work, by the way.