Each database in a sharded cluster has a primary shard. It is the default shard for all unsharded collections in the database. All unsharded collections for a database are created on the database primary shard by default.
The mongos selects the primary shard when creating a new database by picking the shard in the cluster that has the least amount of data.
To change the primary shard for a database, use the movePrimary command.