Getting all graphs with the same probability (that is, getting the uniform distribution) could be desirable. I guess you can use Prüfer codes if you just want a random tree on n vertices. Even in this case, Wilson's algorithm for generating a spanning tree of a graph G uniformly at random is reasonably efficient.

Example: What should be the probability of getting a 4-vertex star (that is, a tree with 3 leaves and a vertex of degree 3)? There are nn - 2 labeled trees (Cayley), and n of those are stars because you can only choose the central vertex, so for n = 4 the correct probability is 4 / 44 - 2 = 1 / 4.